jQuery(document).ready(function ($){
var geocoder;
var autoComplete;
$(".iw-job-advanced_search .range-radius").asRange({
tip: true,
step: 1,
value: parseInt(iwj_search_advanced_radius.radius),
max: parseInt(iwj_search_advanced_radius.max_radius),
min: parseInt(iwj_search_advanced_radius.min_radius),
});
$(".iw-job-advanced_search .range-radius").on('asRange::change', function (e){
var value=$(".iw-job-advanced_search .range-radius").asRange('get');
$(".iw-job-advanced_search input[name='radius']").val(value);
});
function init(){
geocoder=new google.maps.Geocoder();
autoComplete=new google.maps.places.Autocomplete($('.iw-job-advanced_search input[name="address"]').get(0), {
types: []
});
google.maps.event.addListener(autoComplete, 'place_changed', function (){
var place=autoComplete.getPlace();
$(".iw-job-advanced_search input[name='current_lat']").val(place.geometry.location.lat());
$(".iw-job-advanced_search input[name='current_lng']").val(place.geometry.location.lng());
});
$('.iw-job-advanced_search .btn-search').click(function (e){
e.preventDefault();
var value=$(".iw-job-advanced_search input[name='address']").val();
if(value===''){
$(".iw-job-advanced_search input[name='current_lat']").val('');
$(".iw-job-advanced_search input[name='current_lng']").val('');
}
$('.iw-job-advanced_search').find('input').each(function (){
var value=$(this).val();
if(value==''){
$(this).attr('disabled', true);
}});
$('.iw-job-advanced_search').submit();
});
}
$('.iw-job-advanced_search .btn-pinpoint').on('click',function(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var pos={
lat: position.coords.latitude,
lng: position.coords.longitude
};
$(".iw-job-advanced_search input[name='current_lat']").val(position.coords.latitude);
$(".iw-job-advanced_search input[name='current_lng']").val(position.coords.longitude);
geocoder.geocode({'location': pos}, function(results, status){
if(status==='OK'){
if(results[0]){
$(".iw-job-advanced_search input[name='address']").val(results[0].formatted_address);
}}
});
}, function(){
console.log("Browser doesn't support Geolocation");
});
}else{
console.log("Browser doesn't support Geolocation");
}});
init();
});
function InfoBubble(opt_options){
this.extend(InfoBubble, google.maps.OverlayView);
this.tabs_=[];
this.activeTab_=null;
this.baseZIndex_=100;
this.isOpen_=false;
var options=opt_options||{};
if(options['backgroundColor']==undefined){
options['backgroundColor']=this.BACKGROUND_COLOR_;
}
if(options['borderColor']==undefined){
options['borderColor']=this.BORDER_COLOR_;
}
if(options['borderRadius']==undefined){
options['borderRadius']=this.BORDER_RADIUS_;
}
if(options['borderWidth']==undefined){
options['borderWidth']=this.BORDER_WIDTH_;
}
if(options['padding']==undefined){
options['padding']=this.PADDING_;
}
if(options['arrowPosition']==undefined){
options['arrowPosition']=this.ARROW_POSITION_;
}
if(options['disableAutoPan']==undefined){
options['disableAutoPan']=false;
}
if(options['disableAnimation']==undefined){
options['disableAnimation']=false;
}
if(options['minWidth']==undefined){
options['minWidth']=this.MIN_WIDTH_;
}
if(options['shadowStyle']==undefined){
options['shadowStyle']=this.SHADOW_STYLE_;
}
if(options['arrowSize']==undefined){
options['arrowSize']=this.ARROW_SIZE_;
}
if(options['arrowStyle']==undefined){
options['arrowStyle']=this.ARROW_STYLE_;
}
if(options['closeSrc']==undefined){
options['closeSrc']=this.CLOSE_SRC_;
}
this.buildDom_();
this.setValues(options);
}
window['InfoBubble']=InfoBubble;
InfoBubble.prototype.ARROW_SIZE_=15;
InfoBubble.prototype.ARROW_STYLE_=0;
InfoBubble.prototype.SHADOW_STYLE_=1;
InfoBubble.prototype.MIN_WIDTH_=50;
InfoBubble.prototype.ARROW_POSITION_=50;
InfoBubble.prototype.PADDING_=10;
InfoBubble.prototype.BORDER_WIDTH_=1;
InfoBubble.prototype.BORDER_COLOR_='#ccc';
InfoBubble.prototype.BORDER_RADIUS_=10;
InfoBubble.prototype.BACKGROUND_COLOR_='#fff';
InfoBubble.prototype.CLOSE_SRC_='https://maps.gstatic.com/intl/en_us/mapfiles/iw_close.gif';
InfoBubble.prototype.extend=function(obj1, obj2){
return (function(object){
for (var property in object.prototype){
this.prototype[property]=object.prototype[property];
}
return this;
}).apply(obj1, [obj2]);
};
InfoBubble.prototype.buildDom_=function(){
var bubble=this.bubble_=document.createElement('DIV');
bubble.style['position']='absolute';
bubble.style['zIndex']=this.baseZIndex_;
var tabsContainer=this.tabsContainer_=document.createElement('DIV');
tabsContainer.style['position']='relative';
var close=this.close_=document.createElement('IMG');
close.style['position']='absolute';
close.style['border']=0;
close.style['zIndex']=this.baseZIndex_ + 1;
close.style['cursor']='pointer';
close.className='js-info-bubble-close';
close.src=this.get('closeSrc');
var that=this;
google.maps.event.addDomListener(close, 'click', function(){
that.close();
google.maps.event.trigger(that, 'closeclick');
});
var contentContainer=this.contentContainer_=document.createElement('DIV');
contentContainer.style['overflowX']='auto';
contentContainer.style['overflowY']='auto';
contentContainer.style['cursor']='default';
contentContainer.style['clear']='both';
contentContainer.style['position']='relative';
var content=this.content_=document.createElement('DIV');
contentContainer.appendChild(content);
var arrow=this.arrow_=document.createElement('DIV');
arrow.style['position']='relative';
var arrowOuter=this.arrowOuter_=document.createElement('DIV');
var arrowInner=this.arrowInner_=document.createElement('DIV');
var arrowSize=this.getArrowSize_();
arrowOuter.style['position']=arrowInner.style['position']='absolute';
arrowOuter.style['left']=arrowInner.style['left']='50%';
arrowOuter.style['height']=arrowInner.style['height']='0';
arrowOuter.style['width']=arrowInner.style['width']='0';
arrowOuter.style['marginLeft']=this.px(-arrowSize);
arrowOuter.style['borderWidth']=this.px(arrowSize);
arrowOuter.style['borderBottomWidth']=0;
var bubbleShadow=this.bubbleShadow_=document.createElement('DIV');
bubbleShadow.style['position']='absolute';
bubble.style['display']=bubbleShadow.style['display']='none';
bubble.appendChild(this.tabsContainer_);
bubble.appendChild(close);
bubble.appendChild(contentContainer);
arrow.appendChild(arrowOuter);
arrow.appendChild(arrowInner);
bubble.appendChild(arrow);
var stylesheet=document.createElement('style');
stylesheet.setAttribute('type', 'text/css');
this.animationName_='_ibani_' + Math.round(Math.random() * 10000);
var css='.' + this.animationName_ + '{-webkit-animation-name:' +
this.animationName_ + ';-webkit-animation-duration:0.5s;' +
'-webkit-animation-iteration-count:1;}' +
'@-webkit-keyframes ' + this.animationName_ + ' {from {' +
'-webkit-transform: scale(0)}50% {-webkit-transform: scale(1.2)}90% ' +
'{-webkit-transform: scale(0.95)}to {-webkit-transform: scale(1)}}';
stylesheet.textContent=css;
document.getElementsByTagName('head')[0].appendChild(stylesheet);
};
InfoBubble.prototype.setBackgroundClassName=function(className){
this.set('backgroundClassName', className);
};
InfoBubble.prototype['setBackgroundClassName']=InfoBubble.prototype.setBackgroundClassName;
InfoBubble.prototype.backgroundClassName_changed=function(){
this.content_.className=this.get('backgroundClassName');
};
InfoBubble.prototype['backgroundClassName_changed']=InfoBubble.prototype.backgroundClassName_changed;
InfoBubble.prototype.setTabClassName=function(className){
this.set('tabClassName', className);
};
InfoBubble.prototype['setTabClassName']=InfoBubble.prototype.setTabClassName;
InfoBubble.prototype.tabClassName_changed=function(){
this.updateTabStyles_();
};
InfoBubble.prototype['tabClassName_changed']=InfoBubble.prototype.tabClassName_changed;
InfoBubble.prototype.getArrowStyle_=function(){
return parseInt(this.get('arrowStyle'), 10)||0;
};
InfoBubble.prototype.setArrowStyle=function(style){
this.set('arrowStyle', style);
};
InfoBubble.prototype['setArrowStyle']=InfoBubble.prototype.setArrowStyle;
InfoBubble.prototype.arrowStyle_changed=function(){
this.arrowSize_changed();
};
InfoBubble.prototype['arrowStyle_changed']=InfoBubble.prototype.arrowStyle_changed;
InfoBubble.prototype.getArrowSize_=function(){
return parseInt(this.get('arrowSize'), 10)||0;
};
InfoBubble.prototype.setArrowSize=function(size){
this.set('arrowSize', size);
};
InfoBubble.prototype['setArrowSize']=InfoBubble.prototype.setArrowSize;
InfoBubble.prototype.arrowSize_changed=function(){
this.borderWidth_changed();
};
InfoBubble.prototype['arrowSize_changed']=InfoBubble.prototype.arrowSize_changed;
InfoBubble.prototype.setArrowPosition=function(pos){
this.set('arrowPosition', pos);
};
InfoBubble.prototype['setArrowPosition']=InfoBubble.prototype.setArrowPosition;
InfoBubble.prototype.getArrowPosition_=function(){
return parseInt(this.get('arrowPosition'), 10)||0;
};
InfoBubble.prototype.arrowPosition_changed=function(){
var pos=this.getArrowPosition_();
this.arrowOuter_.style['left']=this.arrowInner_.style['left']=pos + '%';
this.redraw_();
};
InfoBubble.prototype['arrowPosition_changed']=InfoBubble.prototype.arrowPosition_changed;
InfoBubble.prototype.setZIndex=function(zIndex){
this.set('zIndex', zIndex);
};
InfoBubble.prototype['setZIndex']=InfoBubble.prototype.setZIndex;
InfoBubble.prototype.getZIndex=function(){
return parseInt(this.get('zIndex'), 10)||this.baseZIndex_;
};
InfoBubble.prototype.zIndex_changed=function(){
var zIndex=this.getZIndex();
this.bubble_.style['zIndex']=this.baseZIndex_=zIndex;
this.close_.style['zIndex']=zIndex + 1;
};
InfoBubble.prototype['zIndex_changed']=InfoBubble.prototype.zIndex_changed;
InfoBubble.prototype.setShadowStyle=function(shadowStyle){
this.set('shadowStyle', shadowStyle);
};
InfoBubble.prototype['setShadowStyle']=InfoBubble.prototype.setShadowStyle;
InfoBubble.prototype.getShadowStyle_=function(){
return parseInt(this.get('shadowStyle'), 10)||0;
};
InfoBubble.prototype.shadowStyle_changed=function(){
var shadowStyle=this.getShadowStyle_();
var display='';
var shadow='';
var backgroundColor='';
switch (shadowStyle){
case 0:
display='none';
break;
case 1:
shadow='0 5px 25px 0 rgba(41, 128, 185, 0.15)';
backgroundColor='transparent';
break;
case 2:
shadow='0 0 2px rgba(33,33,33,0.3)';
backgroundColor='rgba(33,33,33,0.35)';
break;
}
this.bubbleShadow_.style['boxShadow'] =
this.bubbleShadow_.style['webkitBoxShadow'] =
this.bubbleShadow_.style['MozBoxShadow']=shadow;
this.bubbleShadow_.style['backgroundColor']=backgroundColor;
if(this.isOpen_){
this.bubbleShadow_.style['display']=display;
this.draw();
}};
InfoBubble.prototype['shadowStyle_changed']=InfoBubble.prototype.shadowStyle_changed;
InfoBubble.prototype.showCloseButton=function(){
this.set('hideCloseButton', false);
};
InfoBubble.prototype['showCloseButton']=InfoBubble.prototype.showCloseButton;
InfoBubble.prototype.hideCloseButton=function(){
this.set('hideCloseButton', true);
};
InfoBubble.prototype['hideCloseButton']=InfoBubble.prototype.hideCloseButton;
InfoBubble.prototype.hideCloseButton_changed=function(){
this.close_.style['display']=this.get('hideCloseButton') ? 'none':'';
};
InfoBubble.prototype['hideCloseButton_changed']=InfoBubble.prototype.hideCloseButton_changed;
InfoBubble.prototype.setBackgroundColor=function(color){
if(color){
this.set('backgroundColor', color);
}};
InfoBubble.prototype['setBackgroundColor']=InfoBubble.prototype.setBackgroundColor;
InfoBubble.prototype.backgroundColor_changed=function(){
var backgroundColor=this.get('backgroundColor');
this.contentContainer_.style['backgroundColor']=backgroundColor;
this.arrowInner_.style['borderColor']=backgroundColor +
' transparent transparent';
this.updateTabStyles_();
};
InfoBubble.prototype['backgroundColor_changed']=InfoBubble.prototype.backgroundColor_changed;
InfoBubble.prototype.setBorderColor=function(color){
if(color){
this.set('borderColor', color);
}};
InfoBubble.prototype['setBorderColor']=InfoBubble.prototype.setBorderColor;
InfoBubble.prototype.borderColor_changed=function(){
var borderColor=this.get('borderColor');
var contentContainer=this.contentContainer_;
var arrowOuter=this.arrowOuter_;
contentContainer.style['borderColor']=borderColor;
arrowOuter.style['borderColor']=borderColor +
' transparent transparent';
contentContainer.style['borderStyle'] =
arrowOuter.style['borderStyle'] =
this.arrowInner_.style['borderStyle']='solid';
this.updateTabStyles_();
};
InfoBubble.prototype['borderColor_changed']=InfoBubble.prototype.borderColor_changed;
InfoBubble.prototype.setBorderRadius=function(radius){
this.set('borderRadius', radius);
};
InfoBubble.prototype['setBorderRadius']=InfoBubble.prototype.setBorderRadius;
InfoBubble.prototype.getBorderRadius_=function(){
return parseInt(this.get('borderRadius'), 10)||0;
};
InfoBubble.prototype.borderRadius_changed=function(){
var borderRadius=this.getBorderRadius_();
var borderWidth=this.getBorderWidth_();
this.contentContainer_.style['borderRadius'] =
this.contentContainer_.style['MozBorderRadius'] =
this.contentContainer_.style['webkitBorderRadius'] =
this.bubbleShadow_.style['borderRadius'] =
this.bubbleShadow_.style['MozBorderRadius'] =
this.bubbleShadow_.style['webkitBorderRadius']=this.px(borderRadius);
this.tabsContainer_.style['paddingLeft'] =
this.tabsContainer_.style['paddingRight'] =
this.px(borderRadius + borderWidth);
this.redraw_();
};
InfoBubble.prototype['borderRadius_changed']=InfoBubble.prototype.borderRadius_changed;
InfoBubble.prototype.getBorderWidth_=function(){
return parseInt(this.get('borderWidth'), 10)||0;
};
InfoBubble.prototype.setBorderWidth=function(width){
this.set('borderWidth', width);
};
InfoBubble.prototype['setBorderWidth']=InfoBubble.prototype.setBorderWidth;
InfoBubble.prototype.borderWidth_changed=function(){
var borderWidth=this.getBorderWidth_();
this.contentContainer_.style['borderWidth']=this.px(borderWidth);
this.tabsContainer_.style['top']=this.px(borderWidth);
this.updateArrowStyle_();
this.updateTabStyles_();
this.borderRadius_changed();
this.redraw_();
};
InfoBubble.prototype['borderWidth_changed']=InfoBubble.prototype.borderWidth_changed;
InfoBubble.prototype.updateArrowStyle_=function(){
var borderWidth=this.getBorderWidth_();
var arrowSize=this.getArrowSize_();
var arrowStyle=this.getArrowStyle_();
var arrowOuterSizePx=this.px(arrowSize);
var arrowInnerSizePx=this.px(Math.max(0, arrowSize - borderWidth));
var outer=this.arrowOuter_;
var inner=this.arrowInner_;
this.arrow_.style['marginTop']=this.px(-borderWidth);
outer.style['borderTopWidth']=arrowOuterSizePx;
inner.style['borderTopWidth']=arrowInnerSizePx;
if(arrowStyle==0||arrowStyle==1){
outer.style['borderLeftWidth']=arrowOuterSizePx;
inner.style['borderLeftWidth']=arrowInnerSizePx;
}else{
outer.style['borderLeftWidth']=inner.style['borderLeftWidth']=0;
}
if(arrowStyle==0||arrowStyle==2){
outer.style['borderRightWidth']=arrowOuterSizePx;
inner.style['borderRightWidth']=arrowInnerSizePx;
}else{
outer.style['borderRightWidth']=inner.style['borderRightWidth']=0;
}
if(arrowStyle < 2){
outer.style['marginLeft']=this.px(-(arrowSize));
inner.style['marginLeft']=this.px(-(arrowSize - borderWidth));
}else{
outer.style['marginLeft']=inner.style['marginLeft']=0;
}
if(borderWidth==0){
outer.style['display']='none';
}else{
outer.style['display']='';
}};
InfoBubble.prototype.setPadding=function(padding){
this.set('padding', padding);
};
InfoBubble.prototype['setPadding']=InfoBubble.prototype.setPadding;
InfoBubble.prototype.setCloseSrc=function(src){
if(src&&this.close_){
this.close_.src=src;
}};
InfoBubble.prototype['setCloseSrc']=InfoBubble.prototype.setCloseSrc;
InfoBubble.prototype.getPadding_=function(){
return parseInt(this.get('padding'), 10)||0;
};
InfoBubble.prototype.padding_changed=function(){
var padding=this.getPadding_();
this.contentContainer_.style['padding']=this.px(padding);
this.updateTabStyles_();
this.redraw_();
};
InfoBubble.prototype['padding_changed']=InfoBubble.prototype.padding_changed;
InfoBubble.prototype.px=function(num){
if(num){
return num + 'px';
}
return num;
};
InfoBubble.prototype.addEvents_=function(){
var events=['mousedown', 'mousemove', 'mouseover', 'mouseout', 'mouseup',
'mousewheel', 'DOMMouseScroll', 'touchstart', 'touchend', 'touchmove',
'dblclick', 'contextmenu', 'click'];
var bubble=this.bubble_;
this.listeners_=[];
for (var i=0, event; event=events[i]; i++){
this.listeners_.push(google.maps.event.addDomListener(bubble, event, function(e){
e.cancelBubble=true;
if(e.stopPropagation){
e.stopPropagation();
}})
);
}};
InfoBubble.prototype.onAdd=function(){
if(!this.bubble_){
this.buildDom_();
}
this.addEvents_();
var panes=this.getPanes();
if(panes){
panes.floatPane.appendChild(this.bubble_);
panes.floatShadow.appendChild(this.bubbleShadow_);
}
google.maps.event.trigger(this, 'domready');
};
InfoBubble.prototype['onAdd']=InfoBubble.prototype.onAdd;
InfoBubble.prototype.draw=function(){
var projection=this.getProjection();
if(!projection){
return;
}
var latLng= (this.get('position'));
if(!latLng){
this.close();
return;
}
var tabHeight=0;
if(this.activeTab_){
tabHeight=this.activeTab_.offsetHeight;
}
var anchorHeight=this.getAnchorHeight_();
var arrowSize=this.getArrowSize_();
var arrowPosition=this.getArrowPosition_();
arrowPosition=arrowPosition / 100;
var pos=projection.fromLatLngToDivPixel(latLng);
var width=this.contentContainer_.offsetWidth;
var height=this.bubble_.offsetHeight;
if(!width){
return;
}
var top=pos.y - (height + arrowSize);
if(anchorHeight){
top -=anchorHeight;
}
var left=pos.x - (width * arrowPosition);
this.bubble_.style['top']=this.px(top);
this.bubble_.style['left']=this.px(left);
var shadowStyle=parseInt(this.get('shadowStyle'), 10);
switch (shadowStyle){
case 1:
this.bubbleShadow_.style['top']=this.px(top + tabHeight - 1);
this.bubbleShadow_.style['left']=this.px(left);
this.bubbleShadow_.style['width']=this.px(width);
this.bubbleShadow_.style['height'] =
this.px(this.contentContainer_.offsetHeight - arrowSize);
break;
case 2:
width=width * 0.8;
if(anchorHeight){
this.bubbleShadow_.style['top']=this.px(pos.y);
}else{
this.bubbleShadow_.style['top']=this.px(pos.y + arrowSize);
}
this.bubbleShadow_.style['left']=this.px(pos.x - width * arrowPosition);
this.bubbleShadow_.style['width']=this.px(width);
this.bubbleShadow_.style['height']=this.px(2);
break;
}};
InfoBubble.prototype['draw']=InfoBubble.prototype.draw;
InfoBubble.prototype.onRemove=function(){
if(this.bubble_&&this.bubble_.parentNode){
this.bubble_.parentNode.removeChild(this.bubble_);
}
if(this.bubbleShadow_&&this.bubbleShadow_.parentNode){
this.bubbleShadow_.parentNode.removeChild(this.bubbleShadow_);
}
for (var i=0, listener; listener=this.listeners_[i]; i++){
google.maps.event.removeListener(listener);
}};
InfoBubble.prototype['onRemove']=InfoBubble.prototype.onRemove;
InfoBubble.prototype.isOpen=function(){
return this.isOpen_;
};
InfoBubble.prototype['isOpen']=InfoBubble.prototype.isOpen;
InfoBubble.prototype.close=function(){
if(this.bubble_){
this.bubble_.style['display']='none';
this.bubble_.className =
this.bubble_.className.replace(this.animationName_, '');
}
if(this.bubbleShadow_){
this.bubbleShadow_.style['display']='none';
this.bubbleShadow_.className =
this.bubbleShadow_.className.replace(this.animationName_, '');
}
this.isOpen_=false;
};
InfoBubble.prototype['close']=InfoBubble.prototype.close;
InfoBubble.prototype.open=function(opt_map, opt_anchor){
var that=this;
window.setTimeout(function(){
that.open_(opt_map, opt_anchor);
}, 0);
};
InfoBubble.prototype.open_=function(opt_map, opt_anchor){
this.updateContent_();
if(opt_map){
this.setMap(opt_map);
}
if(opt_anchor){
this.set('anchor', opt_anchor);
this.bindTo('anchorPoint', opt_anchor);
this.bindTo('position', opt_anchor);
}
this.bubble_.style['display']=this.bubbleShadow_.style['display']='';
var animation = !this.get('disableAnimation');
if(animation){
this.bubble_.className +=' ' + this.animationName_;
this.bubbleShadow_.className +=' ' + this.animationName_;
}
this.redraw_();
this.isOpen_=true;
var pan = !this.get('disableAutoPan');
if(pan){
var that=this;
window.setTimeout(function(){
that.panToView();
}, 200);
}};
InfoBubble.prototype['open']=InfoBubble.prototype.open;
InfoBubble.prototype.setPosition=function(position){
if(position){
this.set('position', position);
}};
InfoBubble.prototype['setPosition']=InfoBubble.prototype.setPosition;
InfoBubble.prototype.getPosition=function(){
return (this.get('position'));
};
InfoBubble.prototype['getPosition']=InfoBubble.prototype.getPosition;
InfoBubble.prototype.position_changed=function(){
this.draw();
};
InfoBubble.prototype['position_changed']=InfoBubble.prototype.position_changed;
InfoBubble.prototype.panToView=function(){
var projection=this.getProjection();
if(!projection){
return;
}
if(!this.bubble_){
return;
}
var map=this.get('map');
var mapDiv=map.getDiv();
var map_offset=jQuery(mapDiv).offset();
var item_offset=jQuery(this.bubble_).offset();
var centerPos=projection.fromLatLngToContainerPixel(map.getCenter());
var change=false;
if(item_offset.top < map_offset.top){
centerPos.y -=map_offset.top - item_offset.top - 5;
change=true;
}
if(item_offset.left < map_offset.left){
centerPos.x -=map_offset.left - item_offset.left - 5;
change=true;
}else if(item_offset.left + this.bubble_.offsetWidth > mapDiv.offsetWidth + map_offset.left){
centerPos.x +=(item_offset.left + this.bubble_.offsetWidth) - (mapDiv.offsetWidth + map_offset.left) + 25;
change=true;
}
if(change){
latLng=projection.fromContainerPixelToLatLng(centerPos);
map.panTo(latLng);
}};
InfoBubble.prototype['panToView']=InfoBubble.prototype.panToView;
InfoBubble.prototype.htmlToDocumentFragment_=function(htmlString){
htmlString=htmlString.replace(/^\s*([\S\s]*)\b\s*$/, '$1');
var tempDiv=document.createElement('DIV');
tempDiv.innerHTML=htmlString;
if(tempDiv.childNodes.length==1){
return (tempDiv.removeChild(tempDiv.firstChild));
}else{
var fragment=document.createDocumentFragment();
while (tempDiv.firstChild){
fragment.appendChild(tempDiv.firstChild);
}
return fragment;
}};
InfoBubble.prototype.removeChildren_=function(node){
if(!node){
return;
}
var child;
while (child=node.firstChild){
node.removeChild(child);
}};
InfoBubble.prototype.setContent=function(content){
this.set('content', content);
};
InfoBubble.prototype['setContent']=InfoBubble.prototype.setContent;
InfoBubble.prototype.getContent=function(){
return (this.get('content'));
};
InfoBubble.prototype['getContent']=InfoBubble.prototype.getContent;
InfoBubble.prototype.updateContent_=function(){
if(!this.content_){
return;
}
this.removeChildren_(this.content_);
var content=this.getContent();
if(content){
if(typeof content=='string'){
content=this.htmlToDocumentFragment_(content);
}
this.content_.appendChild(content);
var that=this;
var images=this.content_.getElementsByTagName('IMG');
for (var i=0, image; image=images[i]; i++){
google.maps.event.addDomListener(image, 'load', function(){
that.imageLoaded_();
});
}}
this.redraw_();
};
InfoBubble.prototype.imageLoaded_=function(){
var pan = !this.get('disableAutoPan');
this.redraw_();
if(pan&&(this.tabs_.length==0||this.activeTab_.index==0)){
this.panToView();
}};
InfoBubble.prototype.updateTabStyles_=function(){
if(this.tabs_&&this.tabs_.length){
for (var i=0, tab; tab=this.tabs_[i]; i++){
this.setTabStyle_(tab.tab);
}
this.activeTab_.style['zIndex']=this.baseZIndex_;
var borderWidth=this.getBorderWidth_();
var padding=this.getPadding_() / 2;
this.activeTab_.style['borderBottomWidth']=0;
this.activeTab_.style['paddingBottom']=this.px(padding + borderWidth);
}};
InfoBubble.prototype.setTabStyle_=function(tab){
var backgroundColor=this.get('backgroundColor');
var borderColor=this.get('borderColor');
var borderRadius=this.getBorderRadius_();
var borderWidth=this.getBorderWidth_();
var padding=this.getPadding_();
var marginRight=this.px(-(Math.max(padding, borderRadius)));
var borderRadiusPx=this.px(borderRadius);
var index=this.baseZIndex_;
if(tab.index){
index -=tab.index;
}
var styles={
'cssFloat': 'left',
'position': 'relative',
'cursor': 'pointer',
'backgroundColor': backgroundColor,
'border': this.px(borderWidth) + ' solid ' + borderColor,
'padding': this.px(padding / 2) + ' ' + this.px(padding),
'marginRight': marginRight,
'whiteSpace': 'nowrap',
'borderRadiusTopLeft': borderRadiusPx,
'MozBorderRadiusTopleft': borderRadiusPx,
'webkitBorderTopLeftRadius': borderRadiusPx,
'borderRadiusTopRight': borderRadiusPx,
'MozBorderRadiusTopright': borderRadiusPx,
'webkitBorderTopRightRadius': borderRadiusPx,
'zIndex': index,
'display': 'inline'
};
for (var style in styles){
tab.style[style]=styles[style];
}
var className=this.get('tabClassName');
if(className!=undefined){
tab.className +=' ' + className;
}};
InfoBubble.prototype.addTabActions_=function(tab){
var that=this;
tab.listener_=google.maps.event.addDomListener(tab, 'click', function(){
that.setTabActive_(this);
});
};
InfoBubble.prototype.setTabActive=function(index){
var tab=this.tabs_[index - 1];
if(tab){
this.setTabActive_(tab.tab);
}};
InfoBubble.prototype['setTabActive']=InfoBubble.prototype.setTabActive;
InfoBubble.prototype.setTabActive_=function(tab){
if(!tab){
this.setContent('');
this.updateContent_();
return;
}
var padding=this.getPadding_() / 2;
var borderWidth=this.getBorderWidth_();
if(this.activeTab_){
var activeTab=this.activeTab_;
activeTab.style['zIndex']=this.baseZIndex_ - activeTab.index;
activeTab.style['paddingBottom']=this.px(padding);
activeTab.style['borderBottomWidth']=this.px(borderWidth);
}
tab.style['zIndex']=this.baseZIndex_;
tab.style['borderBottomWidth']=0;
tab.style['marginBottomWidth']='-10px';
tab.style['paddingBottom']=this.px(padding + borderWidth);
this.setContent(this.tabs_[tab.index].content);
this.updateContent_();
this.activeTab_=tab;
this.redraw_();
};
InfoBubble.prototype.setMaxWidth=function(width){
this.set('maxWidth', width);
};
InfoBubble.prototype['setMaxWidth']=InfoBubble.prototype.setMaxWidth;
InfoBubble.prototype.maxWidth_changed=function(){
this.redraw_();
};
InfoBubble.prototype['maxWidth_changed']=InfoBubble.prototype.maxWidth_changed;
InfoBubble.prototype.setMaxHeight=function(height){
this.set('maxHeight', height);
};
InfoBubble.prototype['setMaxHeight']=InfoBubble.prototype.setMaxHeight;
InfoBubble.prototype.maxHeight_changed=function(){
this.redraw_();
};
InfoBubble.prototype['maxHeight_changed']=InfoBubble.prototype.maxHeight_changed;
InfoBubble.prototype.setMinWidth=function(width){
this.set('minWidth', width);
};
InfoBubble.prototype['setMinWidth']=InfoBubble.prototype.setMinWidth;
InfoBubble.prototype.minWidth_changed=function(){
this.redraw_();
};
InfoBubble.prototype['minWidth_changed']=InfoBubble.prototype.minWidth_changed;
InfoBubble.prototype.setMinHeight=function(height){
this.set('minHeight', height);
};
InfoBubble.prototype['setMinHeight']=InfoBubble.prototype.setMinHeight;
InfoBubble.prototype.minHeight_changed=function(){
this.redraw_();
};
InfoBubble.prototype['minHeight_changed']=InfoBubble.prototype.minHeight_changed;
InfoBubble.prototype.addTab=function(label, content){
var tab=document.createElement('DIV');
tab.innerHTML=label;
this.setTabStyle_(tab);
this.addTabActions_(tab);
this.tabsContainer_.appendChild(tab);
this.tabs_.push({
label: label,
content: content,
tab: tab
});
tab.index=this.tabs_.length - 1;
tab.style['zIndex']=this.baseZIndex_ - tab.index;
if(!this.activeTab_){
this.setTabActive_(tab);
}
tab.className=tab.className + ' ' + this.animationName_;
this.redraw_();
};
InfoBubble.prototype['addTab']=InfoBubble.prototype.addTab;
InfoBubble.prototype.updateTab=function(index, opt_label, opt_content){
if(!this.tabs_.length||index < 0||index >=this.tabs_.length){
return;
}
var tab=this.tabs_[index];
if(opt_label!=undefined){
tab.tab.innerHTML=tab.label=opt_label;
}
if(opt_content!=undefined){
tab.content=opt_content;
}
if(this.activeTab_==tab.tab){
this.setContent(tab.content);
this.updateContent_();
}
this.redraw_();
};
InfoBubble.prototype['updateTab']=InfoBubble.prototype.updateTab;
InfoBubble.prototype.removeTab=function(index){
if(!this.tabs_.length||index < 0||index >=this.tabs_.length){
return;
}
var tab=this.tabs_[index];
tab.tab.parentNode.removeChild(tab.tab);
google.maps.event.removeListener(tab.tab.listener_);
this.tabs_.splice(index, 1);
delete tab;
for (var i=0, t; t=this.tabs_[i]; i++){
t.tab.index=i;
}
if(tab.tab==this.activeTab_){
if(this.tabs_[index]){
this.activeTab_=this.tabs_[index].tab;
}else if(this.tabs_[index - 1]){
this.activeTab_=this.tabs_[index - 1].tab;
}else{
this.activeTab_=undefined;
}
this.setTabActive_(this.activeTab_);
}
this.redraw_();
};
InfoBubble.prototype['removeTab']=InfoBubble.prototype.removeTab;
InfoBubble.prototype.getElementSize_=function(element, opt_maxWidth,
opt_maxHeight){
var sizer=document.createElement('DIV');
sizer.style['display']='inline';
sizer.style['position']='absolute';
sizer.style['visibility']='hidden';
if(typeof element=='string'){
sizer.innerHTML=element;
}else{
sizer.appendChild(element.cloneNode(true));
}
document.body.appendChild(sizer);
var size=new google.maps.Size(sizer.offsetWidth, sizer.offsetHeight);
if(opt_maxWidth&&size.width > opt_maxWidth){
sizer.style['width']=this.px(opt_maxWidth);
size=new google.maps.Size(sizer.offsetWidth, sizer.offsetHeight);
}
if(opt_maxHeight&&size.height > opt_maxHeight){
sizer.style['height']=this.px(opt_maxHeight);
size=new google.maps.Size(sizer.offsetWidth, sizer.offsetHeight);
}
document.body.removeChild(sizer);
delete sizer;
return size;
};
InfoBubble.prototype.redraw_=function(){
this.figureOutSize_();
this.positionCloseButton_();
this.draw();
};
InfoBubble.prototype.figureOutSize_=function(){
var map=this.get('map');
if(!map){
return;
}
var padding=this.getPadding_();
var borderWidth=this.getBorderWidth_();
var borderRadius=this.getBorderRadius_();
var arrowSize=this.getArrowSize_();
var mapDiv=map.getDiv();
var gutter=arrowSize * 2;
var mapWidth=mapDiv.offsetWidth - gutter;
var mapHeight=mapDiv.offsetHeight - gutter - this.getAnchorHeight_();
var tabHeight=0;
var width= (this.get('minWidth')||0);
var height= (this.get('minHeight')||0);
var maxWidth= (this.get('maxWidth')||0);
var maxHeight= (this.get('maxHeight')||0);
maxWidth=Math.min(mapWidth, maxWidth);
maxHeight=Math.min(mapHeight, maxHeight);
var tabWidth=0;
if(this.tabs_.length){
for (var i=0, tab; tab=this.tabs_[i]; i++){
var tabSize=this.getElementSize_(tab.tab, maxWidth, maxHeight);
var contentSize=this.getElementSize_(tab.content, maxWidth, maxHeight);
if(width < tabSize.width){
width=tabSize.width;
}
tabWidth +=tabSize.width;
if(height < tabSize.height){
height=tabSize.height;
}
if(tabSize.height > tabHeight){
tabHeight=tabSize.height;
}
if(width < contentSize.width){
width=contentSize.width;
}
if(height < contentSize.height){
height=contentSize.height;
}}
}else{
var content= (this.get('content'));
if(typeof content=='string'){
content=this.htmlToDocumentFragment_(content);
}
if(content){
var contentSize=this.getElementSize_(content, maxWidth, maxHeight);
if(width < contentSize.width){
width=contentSize.width;
}
if(height < contentSize.height){
height=contentSize.height;
}}
}
if(maxWidth){
width=Math.min(width, maxWidth);
}
if(maxHeight){
height=Math.min(height, maxHeight);
}
width=Math.max(width, tabWidth);
if(width==tabWidth){
width=width + 2 * padding;
}
arrowSize=arrowSize * 2;
width=Math.max(width, arrowSize);
if(width > mapWidth){
width=mapWidth;
}
if(height > mapHeight){
height=mapHeight - tabHeight;
}
if(this.tabsContainer_){
this.tabHeight_=tabHeight;
this.tabsContainer_.style['width']=this.px(tabWidth);
}
this.contentContainer_.style['width']=this.px(width);
this.contentContainer_.style['height']=this.px(height);
};
InfoBubble.prototype.getAnchorHeight_=function(){
var anchor=this.get('anchor');
if(anchor){
var anchorPoint=(this.get('anchorPoint'));
if(anchorPoint){
return -1 * anchorPoint.y;
}}
return 0;
};
InfoBubble.prototype.anchorPoint_changed=function(){
this.draw();
};
InfoBubble.prototype['anchorPoint_changed']=InfoBubble.prototype.anchorPoint_changed;
InfoBubble.prototype.positionCloseButton_=function(){
var br=this.getBorderRadius_();
var bw=this.getBorderWidth_();
var right=2;
var top=2;
if(this.tabs_.length&&this.tabHeight_){
top +=this.tabHeight_;
}
top +=bw;
right +=bw;
var c=this.contentContainer_;
if(c&&c.clientHeight < c.scrollHeight){
right +=15;
}
this.close_.style['right']=this.px(right);
this.close_.style['top']=this.px(top);
};
function MarkerClusterer(map, opt_markers, opt_options){
this.extend(MarkerClusterer, google.maps.OverlayView);
this.map_=map;
this.markers_=[];
this.clusters_=[];
this.sizes=[53, 56, 66, 78, 90];
this.styles_=[];
this.ready_=false;
var options=opt_options||{};
this.gridSize_=options['gridSize']||60;
this.minClusterSize_=options['minimumClusterSize']||2;
this.maxZoom_=options['maxZoom']||null;
this.styles_=options['styles']||[];
this.imagePath_=options['imagePath'] ||
this.MARKER_CLUSTER_IMAGE_PATH_;
this.imageExtension_=options['imageExtension'] ||
this.MARKER_CLUSTER_IMAGE_EXTENSION_;
this.zoomOnClick_=true;
if(options['zoomOnClick']!=undefined){
this.zoomOnClick_=options['zoomOnClick'];
}
this.averageCenter_=false;
if(options['averageCenter']!=undefined){
this.averageCenter_=options['averageCenter'];
}
this.setupStyles_();
this.setMap(map);
this.prevZoom_=this.map_.getZoom();
var that=this;
google.maps.event.addListener(this.map_, 'zoom_changed', function(){
var zoom=that.map_.getZoom();
var minZoom=that.map_.minZoom||0;
var maxZoom=Math.min(that.map_.maxZoom||100,
that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom);
zoom=Math.min(Math.max(zoom,minZoom),maxZoom);
if(that.prevZoom_!=zoom){
that.prevZoom_=zoom;
that.resetViewport();
}});
google.maps.event.addListener(this.map_, 'idle', function(){
that.redraw();
});
if(opt_markers&&(opt_markers.length||Object.keys(opt_markers).length)){
this.addMarkers(opt_markers, false);
}}
MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_='../images/m';
MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_='png';
MarkerClusterer.prototype.extend=function(obj1, obj2){
return (function(object){
for (var property in object.prototype){
this.prototype[property]=object.prototype[property];
}
return this;
}).apply(obj1, [obj2]);
};
MarkerClusterer.prototype.onAdd=function(){
this.setReady_(true);
};
MarkerClusterer.prototype.draw=function(){};
MarkerClusterer.prototype.setupStyles_=function(){
if(this.styles_.length){
return;
}
for (var i=0, size; size=this.sizes[i]; i++){
this.styles_.push({
url: this.imagePath_ + (i + 1) + '.' + this.imageExtension_,
height: size,
width: size
});
}};
MarkerClusterer.prototype.fitMapToMarkers=function(){
var markers=this.getMarkers();
var bounds=new google.maps.LatLngBounds();
for (var i=0, marker; marker=markers[i]; i++){
bounds.extend(marker.getPosition());
}
this.map_.fitBounds(bounds);
};
MarkerClusterer.prototype.setStyles=function(styles){
this.styles_=styles;
};
MarkerClusterer.prototype.getStyles=function(){
return this.styles_;
};
MarkerClusterer.prototype.isZoomOnClick=function(){
return this.zoomOnClick_;
};
MarkerClusterer.prototype.isAverageCenter=function(){
return this.averageCenter_;
};
MarkerClusterer.prototype.getMarkers=function(){
return this.markers_;
};
MarkerClusterer.prototype.getTotalMarkers=function(){
return this.markers_.length;
};
MarkerClusterer.prototype.setMaxZoom=function(maxZoom){
this.maxZoom_=maxZoom;
};
MarkerClusterer.prototype.getMaxZoom=function(){
return this.maxZoom_;
};
MarkerClusterer.prototype.calculator_=function(markers, numStyles){
var index=0;
var count=markers.length;
var dv=count;
while (dv!==0){
dv=parseInt(dv / 10, 10);
index++;
}
index=Math.min(index, numStyles);
return {
text: count,
index: index
};};
/**
* Set the calculator function.
*
* @param {function(Array, number)} calculator The function to set as the
* calculator. The function should return a object properties:
* 'text' (string) and 'index' (number).
*
*/
MarkerClusterer.prototype.setCalculator=function(calculator){
this.calculator_=calculator;
};
/**
* Get the calculator function.
*
* @return {function(Array, number)} the calculator function.
*/
MarkerClusterer.prototype.getCalculator=function(){
return this.calculator_;
};
MarkerClusterer.prototype.addMarkers=function(markers, opt_nodraw){
if(markers.length){
for (var i=0, marker; marker=markers[i]; i++){
this.pushMarkerTo_(marker);
}}else if(Object.keys(markers).length){
for (var marker in markers){
this.pushMarkerTo_(markers[marker]);
}}
if(!opt_nodraw){
this.redraw();
}};
MarkerClusterer.prototype.pushMarkerTo_=function(marker){
marker.isAdded=false;
if(marker['draggable']){
var that=this;
google.maps.event.addListener(marker, 'dragend', function(){
marker.isAdded=false;
that.repaint();
});
}
this.markers_.push(marker);
};
MarkerClusterer.prototype.addMarker=function(marker, opt_nodraw){
this.pushMarkerTo_(marker);
if(!opt_nodraw){
this.redraw();
}};
MarkerClusterer.prototype.removeMarker_=function(marker){
var index=-1;
if(this.markers_.indexOf){
index=this.markers_.indexOf(marker);
}else{
for (var i=0, m; m=this.markers_[i]; i++){
if(m==marker){
index=i;
break;
}}
}
if(index==-1){
return false;
}
marker.setMap(null);
this.markers_.splice(index, 1);
return true;
};
MarkerClusterer.prototype.removeMarker=function(marker, opt_nodraw){
var removed=this.removeMarker_(marker);
if(!opt_nodraw&&removed){
this.resetViewport();
this.redraw();
return true;
}else{
return false;
}};
MarkerClusterer.prototype.removeMarkers=function(markers, opt_nodraw){
var markersCopy=markers===this.getMarkers() ? markers.slice():markers;
var removed=false;
for (var i=0, marker; marker=markersCopy[i]; i++){
var r=this.removeMarker_(marker);
removed=removed||r;
}
if(!opt_nodraw&&removed){
this.resetViewport();
this.redraw();
return true;
}};
MarkerClusterer.prototype.setReady_=function(ready){
if(!this.ready_){
this.ready_=ready;
this.createClusters_();
}};
MarkerClusterer.prototype.getTotalClusters=function(){
return this.clusters_.length;
};
MarkerClusterer.prototype.getMap=function(){
return this.map_;
};
MarkerClusterer.prototype.setMap=function(map){
this.map_=map;
};
MarkerClusterer.prototype.getGridSize=function(){
return this.gridSize_;
};
MarkerClusterer.prototype.setGridSize=function(size){
this.gridSize_=size;
};
MarkerClusterer.prototype.getMinClusterSize=function(){
return this.minClusterSize_;
};
MarkerClusterer.prototype.setMinClusterSize=function(size){
this.minClusterSize_=size;
};
MarkerClusterer.prototype.getExtendedBounds=function(bounds){
var projection=this.getProjection();
var tr=new google.maps.LatLng(bounds.getNorthEast().lat(),
bounds.getNorthEast().lng());
var bl=new google.maps.LatLng(bounds.getSouthWest().lat(),
bounds.getSouthWest().lng());
var trPix=projection.fromLatLngToDivPixel(tr);
trPix.x +=this.gridSize_;
trPix.y -=this.gridSize_;
var blPix=projection.fromLatLngToDivPixel(bl);
blPix.x -=this.gridSize_;
blPix.y +=this.gridSize_;
var ne=projection.fromDivPixelToLatLng(trPix);
var sw=projection.fromDivPixelToLatLng(blPix);
bounds.extend(ne);
bounds.extend(sw);
return bounds;
};
MarkerClusterer.prototype.isMarkerInBounds_=function(marker, bounds){
return bounds.contains(marker.getPosition());
};
MarkerClusterer.prototype.clearMarkers=function(){
this.resetViewport(true);
this.markers_=[];
};
MarkerClusterer.prototype.resetViewport=function(opt_hide){
for (var i=0, cluster; cluster=this.clusters_[i]; i++){
cluster.remove();
}
for (var i=0, marker; marker=this.markers_[i]; i++){
marker.isAdded=false;
if(opt_hide){
marker.setMap(null);
}}
this.clusters_=[];
};
MarkerClusterer.prototype.repaint=function(){
var oldClusters=this.clusters_.slice();
this.clusters_.length=0;
this.resetViewport();
this.redraw();
window.setTimeout(function(){
for (var i=0, cluster; cluster=oldClusters[i]; i++){
cluster.remove();
}}, 0);
};
MarkerClusterer.prototype.redraw=function(){
this.createClusters_();
};
MarkerClusterer.prototype.distanceBetweenPoints_=function(p1, p2){
if(!p1||!p2){
return 0;
}
var R=6371;
var dLat=(p2.lat() - p1.lat()) * Math.PI / 180;
var dLon=(p2.lng() - p1.lng()) * Math.PI / 180;
var a=Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(p1.lat() * Math.PI / 180) * Math.cos(p2.lat() * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
var c=2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d=R * c;
return d;
};
MarkerClusterer.prototype.addToClosestCluster_=function(marker){
var distance=40000;
var clusterToAddTo=null;
var pos=marker.getPosition();
for (var i=0, cluster; cluster=this.clusters_[i]; i++){
var center=cluster.getCenter();
if(center){
var d=this.distanceBetweenPoints_(center, marker.getPosition());
if(d < distance){
distance=d;
clusterToAddTo=cluster;
}}
}
if(clusterToAddTo&&clusterToAddTo.isMarkerInClusterBounds(marker)){
clusterToAddTo.addMarker(marker);
}else{
var cluster=new Cluster(this);
cluster.addMarker(marker);
this.clusters_.push(cluster);
}};
MarkerClusterer.prototype.createClusters_=function(){
if(!this.ready_){
return;
}
var mapBounds=new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(),
this.map_.getBounds().getNorthEast());
var bounds=this.getExtendedBounds(mapBounds);
for (var i=0, marker; marker=this.markers_[i]; i++){
if(!marker.isAdded&&this.isMarkerInBounds_(marker, bounds)){
this.addToClosestCluster_(marker);
}}
};
function Cluster(markerClusterer){
this.markerClusterer_=markerClusterer;
this.map_=markerClusterer.getMap();
this.gridSize_=markerClusterer.getGridSize();
this.minClusterSize_=markerClusterer.getMinClusterSize();
this.averageCenter_=markerClusterer.isAverageCenter();
this.center_=null;
this.markers_=[];
this.bounds_=null;
this.clusterIcon_=new ClusterIcon(this, markerClusterer.getStyles(),
markerClusterer.getGridSize());
}
Cluster.prototype.isMarkerAlreadyAdded=function(marker){
if(this.markers_.indexOf){
return this.markers_.indexOf(marker)!=-1;
}else{
for (var i=0, m; m=this.markers_[i]; i++){
if(m==marker){
return true;
}}
}
return false;
};
Cluster.prototype.addMarker=function(marker){
if(this.isMarkerAlreadyAdded(marker)){
return false;
}
if(!this.center_){
this.center_=marker.getPosition();
this.calculateBounds_();
}else{
if(this.averageCenter_){
var l=this.markers_.length + 1;
var lat=(this.center_.lat() * (l-1) + marker.getPosition().lat()) / l;
var lng=(this.center_.lng() * (l-1) + marker.getPosition().lng()) / l;
this.center_=new google.maps.LatLng(lat, lng);
this.calculateBounds_();
}}
marker.isAdded=true;
this.markers_.push(marker);
var len=this.markers_.length;
if(len < this.minClusterSize_&&marker.getMap()!=this.map_){
marker.setMap(this.map_);
}
if(len==this.minClusterSize_){
for (var i=0; i < len; i++){
this.markers_[i].setMap(null);
}}
if(len >=this.minClusterSize_){
marker.setMap(null);
}
this.updateIcon();
return true;
};
Cluster.prototype.getMarkerClusterer=function(){
return this.markerClusterer_;
};
Cluster.prototype.getBounds=function(){
var bounds=new google.maps.LatLngBounds(this.center_, this.center_);
var markers=this.getMarkers();
for (var i=0, marker; marker=markers[i]; i++){
bounds.extend(marker.getPosition());
}
return bounds;
};
Cluster.prototype.remove=function(){
this.clusterIcon_.remove();
this.markers_.length=0;
delete this.markers_;
};
Cluster.prototype.getSize=function(){
return this.markers_.length;
};
Cluster.prototype.getMarkers=function(){
return this.markers_;
};
Cluster.prototype.getCenter=function(){
return this.center_;
};
Cluster.prototype.calculateBounds_=function(){
var bounds=new google.maps.LatLngBounds(this.center_, this.center_);
this.bounds_=this.markerClusterer_.getExtendedBounds(bounds);
};
Cluster.prototype.isMarkerInClusterBounds=function(marker){
return this.bounds_.contains(marker.getPosition());
};
Cluster.prototype.getMap=function(){
return this.map_;
};
Cluster.prototype.updateIcon=function(){
var zoom=this.map_.getZoom();
var mz=this.markerClusterer_.getMaxZoom();
if(mz&&zoom > mz){
for (var i=0, marker; marker=this.markers_[i]; i++){
marker.setMap(this.map_);
}
return;
}
if(this.markers_.length < this.minClusterSize_){
this.clusterIcon_.hide();
return;
}
var numStyles=this.markerClusterer_.getStyles().length;
var sums=this.markerClusterer_.getCalculator()(this.markers_, numStyles);
this.clusterIcon_.setCenter(this.center_);
this.clusterIcon_.setSums(sums);
this.clusterIcon_.show();
};
function ClusterIcon(cluster, styles, opt_padding){
cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView);
this.styles_=styles;
this.padding_=opt_padding||0;
this.cluster_=cluster;
this.center_=null;
this.map_=cluster.getMap();
this.div_=null;
this.sums_=null;
this.visible_=false;
this.setMap(this.map_);
}
ClusterIcon.prototype.triggerClusterClick=function(){
var markerClusterer=this.cluster_.getMarkerClusterer();
google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_);
if(markerClusterer.isZoomOnClick()){
this.map_.fitBounds(this.cluster_.getBounds());
}};
ClusterIcon.prototype.onAdd=function(){
this.div_=document.createElement('DIV');
if(this.visible_){
var pos=this.getPosFromLatLng_(this.center_);
this.div_.style.cssText=this.createCss(pos);
this.div_.innerHTML=this.sums_.text;
}
var panes=this.getPanes();
panes.overlayMouseTarget.appendChild(this.div_);
var that=this;
google.maps.event.addDomListener(this.div_, 'click', function(){
that.triggerClusterClick();
});
};
ClusterIcon.prototype.getPosFromLatLng_=function(latlng){
var pos=this.getProjection().fromLatLngToDivPixel(latlng);
pos.x -=parseInt(this.width_ / 2, 10);
pos.y -=parseInt(this.height_ / 2, 10);
return pos;
};
ClusterIcon.prototype.draw=function(){
if(this.visible_){
var pos=this.getPosFromLatLng_(this.center_);
this.div_.style.top=pos.y + 'px';
this.div_.style.left=pos.x + 'px';
}};
ClusterIcon.prototype.hide=function(){
if(this.div_){
this.div_.style.display='none';
}
this.visible_=false;
};
ClusterIcon.prototype.show=function(){
if(this.div_){
var pos=this.getPosFromLatLng_(this.center_);
this.div_.style.cssText=this.createCss(pos);
this.div_.style.display='';
}
this.visible_=true;
};
ClusterIcon.prototype.remove=function(){
this.setMap(null);
};
ClusterIcon.prototype.onRemove=function(){
if(this.div_&&this.div_.parentNode){
this.hide();
this.div_.parentNode.removeChild(this.div_);
this.div_=null;
}};
ClusterIcon.prototype.setSums=function(sums){
this.sums_=sums;
this.text_=sums.text;
this.index_=sums.index;
if(this.div_){
this.div_.innerHTML=sums.text;
}
this.useStyle();
};
ClusterIcon.prototype.useStyle=function(){
var index=Math.max(0, this.sums_.index - 1);
index=Math.min(this.styles_.length - 1, index);
var style=this.styles_[index];
this.url_=style['url'];
this.height_=style['height'];
this.width_=style['width'];
this.textColor_=style['textColor'];
this.anchor_=style['anchor'];
this.textSize_=style['textSize'];
this.backgroundPosition_=style['backgroundPosition'];
};
ClusterIcon.prototype.setCenter=function(center){
this.center_=center;
};
ClusterIcon.prototype.createCss=function(pos){
var style=[];
style.push('background-image:url(' + this.url_ + ');');
var backgroundPosition=this.backgroundPosition_ ? this.backgroundPosition_:'0 0';
style.push('background-position:' + backgroundPosition + ';');
if(typeof this.anchor_==='object'){
if(typeof this.anchor_[0]==='number'&&this.anchor_[0] > 0 &&
this.anchor_[0] < this.height_){
style.push('height:' + (this.height_ - this.anchor_[0]) +
'px; padding-top:' + this.anchor_[0] + 'px;');
}else{
style.push('height:' + this.height_ + 'px; line-height:' + this.height_ +
'px;');
}
if(typeof this.anchor_[1]==='number'&&this.anchor_[1] > 0 &&
this.anchor_[1] < this.width_){
style.push('width:' + (this.width_ - this.anchor_[1]) +
'px; padding-left:' + this.anchor_[1] + 'px;');
}else{
style.push('width:' + this.width_ + 'px; text-align:center;');
}}else{
style.push('height:' + this.height_ + 'px; line-height:' +
this.height_ + 'px; width:' + this.width_ + 'px; text-align:center;');
}
var txtColor=this.textColor_ ? this.textColor_:'black';
var txtSize=this.textSize_ ? this.textSize_:11;
style.push('cursor:pointer; top:' + pos.y + 'px; left:' +
pos.x + 'px; color:' + txtColor + '; position:absolute; font-size:' +
txtSize + 'px; font-family:Arial,sans-serif; font-weight:bold');
return style.join('');
};
window['MarkerClusterer']=MarkerClusterer;
MarkerClusterer.prototype['addMarker']=MarkerClusterer.prototype.addMarker;
MarkerClusterer.prototype['addMarkers']=MarkerClusterer.prototype.addMarkers;
MarkerClusterer.prototype['clearMarkers'] =
MarkerClusterer.prototype.clearMarkers;
MarkerClusterer.prototype['fitMapToMarkers'] =
MarkerClusterer.prototype.fitMapToMarkers;
MarkerClusterer.prototype['getCalculator'] =
MarkerClusterer.prototype.getCalculator;
MarkerClusterer.prototype['getGridSize'] =
MarkerClusterer.prototype.getGridSize;
MarkerClusterer.prototype['getExtendedBounds'] =
MarkerClusterer.prototype.getExtendedBounds;
MarkerClusterer.prototype['getMap']=MarkerClusterer.prototype.getMap;
MarkerClusterer.prototype['getMarkers']=MarkerClusterer.prototype.getMarkers;
MarkerClusterer.prototype['getMaxZoom']=MarkerClusterer.prototype.getMaxZoom;
MarkerClusterer.prototype['getStyles']=MarkerClusterer.prototype.getStyles;
MarkerClusterer.prototype['getTotalClusters'] =
MarkerClusterer.prototype.getTotalClusters;
MarkerClusterer.prototype['getTotalMarkers'] =
MarkerClusterer.prototype.getTotalMarkers;
MarkerClusterer.prototype['redraw']=MarkerClusterer.prototype.redraw;
MarkerClusterer.prototype['removeMarker'] =
MarkerClusterer.prototype.removeMarker;
MarkerClusterer.prototype['removeMarkers'] =
MarkerClusterer.prototype.removeMarkers;
MarkerClusterer.prototype['resetViewport'] =
MarkerClusterer.prototype.resetViewport;
MarkerClusterer.prototype['repaint'] =
MarkerClusterer.prototype.repaint;
MarkerClusterer.prototype['setCalculator'] =
MarkerClusterer.prototype.setCalculator;
MarkerClusterer.prototype['setGridSize'] =
MarkerClusterer.prototype.setGridSize;
MarkerClusterer.prototype['setMaxZoom'] =
MarkerClusterer.prototype.setMaxZoom;
MarkerClusterer.prototype['onAdd']=MarkerClusterer.prototype.onAdd;
MarkerClusterer.prototype['draw']=MarkerClusterer.prototype.draw;
Cluster.prototype['getCenter']=Cluster.prototype.getCenter;
Cluster.prototype['getSize']=Cluster.prototype.getSize;
Cluster.prototype['getMarkers']=Cluster.prototype.getMarkers;
ClusterIcon.prototype['onAdd']=ClusterIcon.prototype.onAdd;
ClusterIcon.prototype['draw']=ClusterIcon.prototype.draw;
ClusterIcon.prototype['onRemove']=ClusterIcon.prototype.onRemove;
Object.keys=Object.keys||function(o){
var result=[];
for(var name in o){
if(o.hasOwnProperty(name))
result.push(name);
}
return result;
};
;(function (root, factory){
if(typeof module=='object'&&module.exports) module.exports=factory()
else if(typeof define=='function'&&define.amd) define(factory)
else root.Spinner=factory()
}(this, function (){
"use strict"
var prefixes=['webkit', 'Moz', 'ms', 'O']
, animations={}
, useCssAnimations
, sheet
function createEl (tag, prop){
var el=document.createElement(tag||'div')
, n
for (n in prop) el[n]=prop[n]
return el
}
function ins (parent ){
for (var i=1, n=arguments.length; i < n; i++){
parent.appendChild(arguments[i])
}
return parent
}
function addAnimation (alpha, trail, i, lines){
var name=['opacity', trail, ~~(alpha * 100), i, lines].join('-')
, start=0.01 + i/lines * 100
, z=Math.max(1 - (1-alpha) / trail * (100-start), alpha)
, prefix=useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
, pre=prefix&&'-' + prefix + '-'||''
if(!animations[name]){
sheet.insertRule('@' + pre + 'keyframes ' + name + '{' +
'0%{opacity:' + z + '}' +
start + '%{opacity:' + alpha + '}' +
(start+0.01) + '%{opacity:1}' +
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
'100%{opacity:' + z + '}' +
'}', sheet.cssRules.length)
animations[name]=1
}
return name
}
function vendor (el, prop){
var s=el.style
, pp
, i
prop=prop.charAt(0).toUpperCase() + prop.slice(1)
if(s[prop]!==undefined) return prop
for (i=0; i < prefixes.length; i++){
pp=prefixes[i]+prop
if(s[pp]!==undefined) return pp
}}
function css (el, prop){
for (var n in prop){
el.style[vendor(el, n)||n]=prop[n]
}
return el
}
function merge (obj){
for (var i=1; i < arguments.length; i++){
var def=arguments[i]
for (var n in def){
if(obj[n]===undefined) obj[n]=def[n]
}}
return obj
}
function getColor (color, idx){
return typeof color=='string' ? color:color[idx % color.length]
}
var defaults={
lines: 12
, length: 7
, width: 5
, radius: 10
, scale: 1.0
, corners: 1
, color: '#000'
, opacity: 1/4
, rotate: 0
, direction: 1
, speed: 1
, trail: 100
, fps: 20
, zIndex: 2e9
, className: 'spinner'
, top: '50%'
, left: '50%'
, shadow: false
, hwaccel: false
, position: 'absolute'
}
function Spinner (o){
this.opts=merge(o||{}, Spinner.defaults, defaults)
}
Spinner.defaults={}
merge(Spinner.prototype, {
spin: function (target){
this.stop()
var self=this
, o=self.opts
, el=self.el=createEl(null, {className: o.className})
css(el, {
position: o.position
, width: 0
, zIndex: o.zIndex
, left: o.left
, top: o.top
})
if(target){
target.insertBefore(el, target.firstChild||null)
}
el.setAttribute('role', 'progressbar')
self.lines(el, self.opts)
if(!useCssAnimations){
var i=0
, start=(o.lines - 1) * (1 - o.direction) / 2
, alpha
, fps=o.fps
, f=fps / o.speed
, ostep=(1 - o.opacity) / (f * o.trail / 100)
, astep=f / o.lines
;(function anim (){
i++
for (var j=0; j < o.lines; j++){
alpha=Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
self.opacity(el, j * o.direction + start, alpha, o)
}
self.timeout=self.el&&setTimeout(anim, ~~(1000 / fps))
})()
}
return self
}
, stop: function (){
var el=this.el
if(el){
clearTimeout(this.timeout)
if(el.parentNode) el.parentNode.removeChild(el)
this.el=undefined
}
return this
}
, lines: function (el, o){
var i=0
, start=(o.lines - 1) * (1 - o.direction) / 2
, seg
function fill (color, shadow){
return css(createEl(), {
position: 'absolute'
, width: o.scale * (o.length + o.width) + 'px'
, height: o.scale * o.width + 'px'
, background: color
, boxShadow: shadow
, transformOrigin: 'left'
, transform: 'rotate(' + ~~(360/o.lines*i + o.rotate) + 'deg) translate(' + o.scale*o.radius + 'px' + ',0)'
, borderRadius: (o.corners * o.scale * o.width >> 1) + 'px'
})
}
for (; i < o.lines; i++){
seg=css(createEl(), {
position: 'absolute'
, top: 1 + ~(o.scale * o.width / 2) + 'px'
, transform: o.hwaccel ? 'translate3d(0,0,0)':''
, opacity: o.opacity
, animation: useCssAnimations&&addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1 / o.speed + 's linear infinite'
})
if(o.shadow) ins(seg, css(fill('#000', '0 0 4px #000'), {top: '2px'}))
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
}
return el
}
, opacity: function (el, i, val){
if(i < el.childNodes.length) el.childNodes[i].style.opacity=val
}})
function initVML (){
function vml (tag, attr){
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
}
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
Spinner.prototype.lines=function (el, o){
var r=o.scale * (o.length + o.width)
, s=o.scale * 2 * r
function grp (){
return css(
vml('group', {
coordsize: s + ' ' + s
, coordorigin: -r + ' ' + -r
})
, { width: s, height: s }
)
}
var margin=-(o.width + o.length) * o.scale * 2 + 'px'
, g=css(grp(), {position: 'absolute', top: margin, left: margin})
, i
function seg (i, dx, filter){
ins(
g
, ins(
css(grp(), {rotation: 360 / o.lines * i + 'deg', left: ~~dx})
, ins(
css(
vml('roundrect', {arcsize: o.corners})
, { width: r
, height: o.scale * o.width
, left: o.scale * o.radius
, top: -o.scale * o.width >> 1
, filter: filter
}
)
, vml('fill', {color: getColor(o.color, i), opacity: o.opacity})
, vml('stroke', {opacity: 0})
)
)
)
}
if(o.shadow)
for (i=1; i <=o.lines; i++){
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
}
for (i=1; i <=o.lines; i++) seg(i)
return ins(el, g)
}
Spinner.prototype.opacity=function (el, i, val, o){
var c=el.firstChild
o=o.shadow&&o.lines||0
if(c&&i + o < c.childNodes.length){
c=c.childNodes[i + o]; c=c&&c.firstChild; c=c&&c.firstChild
if(c) c.opacity=val
}}
}
if(typeof document!=='undefined'){
sheet=(function (){
var el=createEl('style', {type:'text/css'})
ins(document.getElementsByTagName('head')[0], el)
return el.sheet||el.styleSheet
}())
var probe=css(createEl('group'), {behavior: 'url(#default#VML)'})
if(!vendor(probe, 'transform')&&probe.adj) initVML()
else useCssAnimations=vendor(probe, 'animation')
}
return Spinner
}));
(function ($){
"use strict";
$.fn.iwjSimpleMap=function (getdata){
$(this).each(function (){
var self=$(this),
js_array_map=iwj_findjob_map.js_array_map,
icon=iwj_findjob_map.marker_icon,
lat=parseFloat(iwj_findjob_map.latitude),
long=parseFloat(iwj_findjob_map.longitude),
path_image_google=iwj_findjob_map.path_image_google,
check_search=iwj_findjob_map.check_search;
var loc=new google.maps.LatLng(lat, long);
var mapOptions={
scrollwheel: false,
draggable: true,
zoom: parseInt(iwj_findjob_map.zoom),
center: loc,
styles:
(iwj_findjob_map.map_styles ? JSON.parse(iwj_findjob_map.map_styles):[
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#444444"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"color": "#f2f2f2"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#46bcec"
},
{
"visibility": "on"
}
]
}
])
};
var map=new google.maps.Map($(this).find('.map-view').get(0), mapOptions);
var marker, i;
if(iwj_findjob_map.auto_center==='yes'){
var bounds=new google.maps.LatLngBounds();
}
var markers=[];
var saved_list=[];
if(getdata){
js_array_map=getdata;
check_search='1';
}
var infobox=new InfoBubble({
content: ' ',
shadowStyle: 1,
maxWidth: 280,
minWidth: 260,
minHeight: 230,
maxHeight: 900,
padding: 30,
backgroundColor: '#fff',
borderRadius: 5,
arrowSize: 25,
borderWidth: 1,
borderColor: 'transparent',
disableAutoPan: false,
hideCloseButton: false,
arrowPosition: 50,
backgroundClassName: 'infor-search-map',
arrowStyle: 0,
closeSrc: iwj_findjob_map.close_icon
});
for (i=0; i < js_array_map.length; i++){
var infowindow=new google.maps.InfoWindow({maxWidth: 250});
marker=new google.maps.Marker({
position: new google.maps.LatLng(js_array_map[i].lat, js_array_map[i].lng),
map: map,
icon: icon,
});
if(iwj_findjob_map.auto_center==='yes'){
bounds.extend(marker.position);
}
markers.push(marker);
google.maps.event.addListener(marker, 'click', (function (marker, i){
return function (){
var contentdata='';
var content='';
var is_saved='';
if(jQuery.inArray(js_array_map[i].id, saved_list)!='-1'){
is_saved='saved ';
}
content +='
';
content +='
';
if(js_array_map[i].company_name!=''){
content +='
';
}
if(js_array_map[i].salary!=''){
content +='
' + js_array_map[i].salary + '
';
}
if(js_array_map[i].location!=''){
content +='
' + js_array_map[i].location + '
';
}
content +='
';
if(js_array_map[i].link_type!=''&&js_array_map[i].color!=''){
content +='
' + js_array_map[i].type + '';
}
if(js_array_map[i].check_login==='1'){
content +='
';
}else{
content +='
';
}
content +='
';
content +='';
contentdata=$(content);
contentdata.on('click', '.iwj-save-job', function (e){
e.preventDefault();
var self=$(this);
var id=$(this).data('id');
var in_list=$(this).data('in-list');
var ori_class='';
if(self.hasClass('saved')){
var data='action=iwj_undo_save_job&_ajax_nonce=' + iwj.security + '&id=' + id;
}else{
var data='action=iwj_save_job&_ajax_nonce=' + iwj.security + '&id=' + id;
}
$.ajax({
url: iwj.ajax_url,
type: 'POST',
data: data,
dataType: 'json',
beforeSend: function (){
if(in_list){
ori_class=self.find('i').attr('class');
self.find('i').attr('class', 'fa fa-spinner fa-spin');
}else{
iwj_button_loader(self, 'add');
}},
success: function (result){
if(result){
iwj_button_loader(self, 'remove');
if(result.success==true){
var index=saved_list.indexOf(id);
if(self.hasClass('saved')){
self.removeClass('saved');
if(index > -1){
saved_list.splice(index, 1);
}}else{
self.addClass('saved');
if(index < 1){
saved_list.push(id);
}}
if(!in_list){
self.html(result.message);
}}
if(in_list){
self.find('i').attr('class', ori_class);
}}
}});
});
contentdata.on('mouseenter', 'a[data-color]', function (){
var color=$(this).data('color');
if(color){
var ori_background=$(this).css('background-color');
$(this).data('ori-background-color', ori_background);
$(this).css({'background-color': color});
}});
contentdata.on('mouseout', 'a[data-color]', function (){
var color=$(this).data('ori-background-color');
$(this).css({'background-color': color});
});
if(infobox){
infobox.close();
}
infobox.setContent(contentdata.get(0));
infobox.open(map, marker);
}})(marker, i));
}
var markerCluster=new MarkerClusterer(map, markers, {imagePath: path_image_google});
if(iwj_findjob_map.auto_center==='yes'){
map.fitBounds(bounds);
}});
};
$.fn.iwjSimpleMapNone=function (lat, long){
$(this).each(function (){
var latdata=lat;
var lngdata=long;
var self=$(this),
js_array_map='',
icon=iwj_findjob_map.marker_icon;
var loc=new google.maps.LatLng(latdata, lngdata);
var mapOptions={
scrollwheel: false,
draggable: true,
zoom: parseInt(iwj_findjob_map.zoom),
center: loc,
styles:
(iwj_findjob_map.map_styles ? JSON.parse(iwj_findjob_map.map_styles):[
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#444444"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"color": "#f2f2f2"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#46bcec"
},
{
"visibility": "on"
}
]
}
])
};
var map=new google.maps.Map($(this).find('.map-view').get(0), mapOptions);
var marker, i;
for (i=0; i < js_array_map.length; i++){
var infowindow=new google.maps.InfoWindow({maxWidth: 250});
marker=new google.maps.Marker({
position: new google.maps.LatLng(js_array_map[i].lat, js_array_map[i].lng),
map: map,
icon: icon,
});
google.maps.event.addListener(marker, 'click', (function (marker, i){
return function (){
var contentdata='';
var content='';
content +='';
content +='
';
content +='
' + js_array_map[i].salary + '
';
content +='
' + js_array_map[i].location + '
';
if(js_array_map[i].link_type!=''&&js_array_map[i].color!=''){
content +='
';
}else{
content +='
';
}
content +='
';
contentdata=content;
infowindow.setContent(contentdata);
infowindow.open(map, marker);
}})(marker, i));
}});
};
$(window).load(function (){
$(".map-contain-find-job").iwjSimpleMap();
});
$('.keywords-trending').click(function (e){
e.preventDefault();
var data='';
var self=$(this);
var keywords=self.data('keywords');
var opts={
lines: 13
, length: 28
, width: 14
, radius: 42
, scale: 1
, corners: 1
, color: '#000'
, opacity: 0.25
, rotate: 0
, direction: 1
, speed: 1
, trail: 60
, fps: 20
, zIndex: 2e9
, className: 'spinner'
, top: '50%'
, left: '50%'
, shadow: false
, hwaccel: false
, position: 'absolute'
};
var target=document.getElementById('spin-map');
var data='action=iwj_findjob_map&_ajax_nonce=' + iwj.security + '&keyword=' + keywords;
$.ajax({
url: iwj.ajax_url,
type: 'GET',
data: data,
dataType: 'json',
beforeSend: function (){
var spinner=new Spinner(opts).spin(target);
},
success: function (result){
if(result){
$(".map-contain-find-job").iwjSimpleMap(result);
}
$(".spinner").delay(2000).queue(function (){
$(this).remove();
});
}});
});
$('.iwj-login-form-maps').submit(function (e){
e.preventDefault();
var self=$(this);
var button=self.find('.iwj-login-btn');
var data=self.serialize();
var opts={
lines: 13
, length: 28
, width: 14
, radius: 42
, scale: 1
, corners: 1
, color: '#000'
, opacity: 0.25
, rotate: 0
, direction: 1
, speed: 1
, trail: 60
, fps: 20
, zIndex: 2e9
, className: 'spinner'
, top: '50%'
, left: '50%'
, shadow: false
, hwaccel: false
, position: 'absolute'
};
var target=document.getElementById('spin-map');
data='action=iwj_findjob_map&_ajax_nonce=' + iwj.security + '&' + data;
$.ajax({
url: iwj.ajax_url,
type: 'GET',
data: data,
dataType: 'json',
beforeSend: function (){
var spinner=new Spinner(opts).spin(target);
},
success: function (result){
if(result.none_data!='0'){
$(".map-contain-find-job").iwjSimpleMap(result);
}else{
if(result.location){
var geocoder, lat, long;
geocoder=new google.maps.Geocoder();
geocoder.geocode({'address': result.location}, function (results, status){
if(status==google.maps.GeocoderStatus.OK){
lat=results[0].geometry.location.lat();
long=results[0].geometry.location.lng();
$(".map-contain-find-job").iwjSimpleMapNone(lat, long);
}else{
alert("Geocode was not successful for the following reason: " + status);
}});
}else{
var lat=parseFloat(iwj_findjob_map.latitude),
log=parseFloat(iwj_findjob_map.longitude);
$(".map-contain-find-job").iwjSimpleMapNone(lat, log);
}}
$(".spinner").delay(2000).queue(function (){
$(this).remove();
});
}});
});
})(jQuery);
!function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,s,a){function u(t,e,o){var n,s="$()."+i+'("'+e+'")';return t.each(function(t,u){var h=a.data(u,i);if(!h)return void r(i+" not initialized. Cannot call methods, i.e. "+s);var d=h[e];if(!d||"_"==e.charAt(0))return void r(s+" is not a valid method");var l=d.apply(h,o);n=void 0===n?l:n}),void 0!==n?n:t}function h(t,e){t.each(function(t,o){var n=a.data(o,i);n?(n.option(e),n._init()):(n=new s(o,e),a.data(o,i,n))})}a=a||e||t.jQuery,a&&(s.prototype.option||(s.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=n.call(arguments,1);return u(this,t,e)}return h(this,t),this},o(a))}function o(t){!t||t&&t.bridget||(t.bridget=i)}var n=Array.prototype.slice,s=t.console,r="undefined"==typeof s?function(){}:function(t){s.error(t)};return o(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},o=i[t]=i[t]||[];return o.indexOf(e)==-1&&o.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},o=i[t]=i[t]||{};return o[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var o=i.indexOf(e);return o!=-1&&i.splice(o,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){i=i.slice(0),e=e||[];for(var o=this._onceEvents&&this._onceEvents[t],n=0;n1&&i+t>this.cols;i=o?0:i;var n=e.size.outerWidth&&e.size.outerHeight;return this.horizontalColIndex=n?i+t:this.horizontalColIndex,{col:i,y:this._getColGroupY(i,t)}},o._manageStamp=function(t){var i=e(t),o=this._getElementOffset(t),n=this._getOption("originLeft"),s=n?o.left:o.right,r=s+i.outerWidth,a=Math.floor(s/this.columnWidth);a=Math.max(0,a);var u=Math.floor(r/this.columnWidth);u-=r%this.columnWidth?0:1,u=Math.min(this.cols-1,u);for(var h=this._getOption("originTop"),d=(h?o.top:o.bottom)+i.outerHeight,l=a;l<=u;l++)this.colYs[l]=Math.max(d,this.colYs[l])},o._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var t={height:this.maxY};return this._getOption("fitWidth")&&(t.width=this._getContainerFitWidth()),t},o._getContainerFitWidth=function(){for(var t=0,e=this.cols;--e&&0===this.colYs[e];)t++;return(this.cols-t)*this.columnWidth-this.gutter},o.needsResizeLayout=function(){var t=this.containerWidth;return this.getContainerWidth(),t!=this.containerWidth},i}),function(t,e){"function"==typeof define&&define.amd?define("isotope-layout/js/layout-modes/masonry",["../layout-mode","masonry-layout/masonry"],e):"object"==typeof module&&module.exports?module.exports=e(require("../layout-mode"),require("masonry-layout")):e(t.Isotope.LayoutMode,t.Masonry)}(window,function(t,e){"use strict";var i=t.create("masonry"),o=i.prototype,n={_getElementOffset:!0,layout:!0,_getMeasurement:!0};for(var s in e.prototype)n[s]||(o[s]=e.prototype[s]);var r=o.measureColumns;o.measureColumns=function(){this.items=this.isotope.filteredItems,r.call(this)};var a=o._getOption;return o._getOption=function(t){return"fitWidth"==t?void 0!==this.options.isFitWidth?this.options.isFitWidth:this.options.fitWidth:a.apply(this.isotope,arguments)},i}),function(t,e){"function"==typeof define&&define.amd?define("isotope-layout/js/layout-modes/fit-rows",["../layout-mode"],e):"object"==typeof exports?module.exports=e(require("../layout-mode")):e(t.Isotope.LayoutMode)}(window,function(t){"use strict";var e=t.create("fitRows"),i=e.prototype;return i._resetLayout=function(){this.x=0,this.y=0,this.maxY=0,this._getMeasurement("gutter","outerWidth")},i._getItemLayoutPosition=function(t){t.getSize();var e=t.size.outerWidth+this.gutter,i=this.isotope.size.innerWidth+this.gutter;0!==this.x&&e+this.x>i&&(this.x=0,this.y=this.maxY);var o={x:this.x,y:this.y};return this.maxY=Math.max(this.maxY,this.y+t.size.outerHeight),this.x+=e,o},i._getContainerSize=function(){return{height:this.maxY}},e}),function(t,e){"function"==typeof define&&define.amd?define("isotope-layout/js/layout-modes/vertical",["../layout-mode"],e):"object"==typeof module&&module.exports?module.exports=e(require("../layout-mode")):e(t.Isotope.LayoutMode)}(window,function(t){"use strict";var e=t.create("vertical",{horizontalAlignment:0}),i=e.prototype;return i._resetLayout=function(){this.y=0},i._getItemLayoutPosition=function(t){t.getSize();var e=(this.isotope.size.innerWidth-t.size.outerWidth)*this.options.horizontalAlignment,i=this.y;return this.y+=t.size.outerHeight,{x:e,y:i}},i._getContainerSize=function(){return{height:this.y}},e}),function(t,e){"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size","desandro-matches-selector/matches-selector","fizzy-ui-utils/utils","isotope-layout/js/item","isotope-layout/js/layout-mode","isotope-layout/js/layout-modes/masonry","isotope-layout/js/layout-modes/fit-rows","isotope-layout/js/layout-modes/vertical"],function(i,o,n,s,r,a){return e(t,i,o,n,s,r,a)}):"object"==typeof module&&module.exports?module.exports=e(t,require("outlayer"),require("get-size"),require("desandro-matches-selector"),require("fizzy-ui-utils"),require("isotope-layout/js/item"),require("isotope-layout/js/layout-mode"),require("isotope-layout/js/layout-modes/masonry"),require("isotope-layout/js/layout-modes/fit-rows"),require("isotope-layout/js/layout-modes/vertical")):t.Isotope=e(t,t.Outlayer,t.getSize,t.matchesSelector,t.fizzyUIUtils,t.Isotope.Item,t.Isotope.LayoutMode)}(window,function(t,e,i,o,n,s,r){function a(t,e){return function(i,o){for(var n=0;na||ra?1:-1)*h}}return 0}}var u=t.jQuery,h=String.prototype.trim?function(t){return t.trim()}:function(t){return t.replace(/^\s+|\s+$/g,"")},d=e.create("isotope",{layoutMode:"masonry",isJQueryFiltering:!0,sortAscending:!0});d.Item=s,d.LayoutMode=r;var l=d.prototype;l._create=function(){this.itemGUID=0,this._sorters={},this._getSorters(),e.prototype._create.call(this),this.modes={},this.filteredItems=this.items,this.sortHistory=["original-order"];for(var t in r.modes)this._initLayoutMode(t)},l.reloadItems=function(){this.itemGUID=0,e.prototype.reloadItems.call(this)},l._itemize=function(){for(var t=e.prototype._itemize.apply(this,arguments),i=0;i").outerWidth(1).jquery||a.each(["Width","Height"],function(e,n){var r="Width"===n?["Left","Right"]:["Top","Bottom"],i=n.toLowerCase(),o={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};function s(e,t,n,i){return a.each(r,function(){t-=parseFloat(a.css(e,"padding"+this))||0,n&&(t-=parseFloat(a.css(e,"border"+this+"Width"))||0),i&&(t-=parseFloat(a.css(e,"margin"+this))||0)}),t}a.fn["inner"+n]=function(e){return void 0===e?o["inner"+n].call(this):this.each(function(){a(this).css(i,s(this,e)+"px")})},a.fn["outer"+n]=function(e,t){return"number"!=typeof e?o["outer"+n].call(this,e):this.each(function(){a(this).css(i,s(this,e,!0,t)+"px")})}}),a.fn.addBack||(a.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),a("").data("a-b","a").removeData("a-b").data("a-b")&&(a.fn.removeData=(t=a.fn.removeData,function(e){return arguments.length?t.call(this,a.camelCase(e)):t.call(this)})),a.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),a.fn.extend({focus:(i=a.fn.focus,function(t,n){return"number"==typeof t?this.each(function(){var e=this;setTimeout(function(){a(e).focus(),n&&n.call(e)},t)}):i.apply(this,arguments)}),disableSelection:(n="onselectstart"in document.createElement("div")?"selectstart":"mousedown",function(){return this.bind(n+".ui-disableSelection",function(e){e.preventDefault()})}),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(e){if(void 0!==e)return this.css("zIndex",e);if(this.length)for(var t,n,i=a(this[0]);i.length&&i[0]!==document;){if(("absolute"===(t=i.css("position"))||"relative"===t||"fixed"===t)&&(n=parseInt(i.css("zIndex"),10),!isNaN(n)&&0!==n))return n;i=i.parent()}return 0}}),a.ui.plugin={add:function(e,t,n){var i,r=a.ui[e].prototype;for(i in n)r.plugins[i]=r.plugins[i]||[],r.plugins[i].push([t,n[i]])},call:function(e,t,n,i){var r,o=e.plugins[t];if(o&&(i||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(r=0;r",options:{disabled:!1,create:null},_createWidget:function(t,e){e=h(e||this.defaultElement||this)[0],this.element=h(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=h(),this.hoverable=h(),this.focusable=h(),e!==this&&(h.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=h(e.style?e.ownerDocument:e.document||e),this.window=h(this.document[0].defaultView||this.document[0].parentWindow)),this.options=h.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:h.noop,_getCreateEventData:h.noop,_create:h.noop,_init:h.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(h.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:h.noop,widget:function(){return this.element},option:function(t,e){var i,n,s,o=t;if(0===arguments.length)return h.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(n=o[t]=h.widget.extend({},this.options[t]),s=0;s=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})});
!function(t){"function"==typeof define&&define.amd?define(["jquery","./core","./mouse","./widget"],t):t(jQuery)}(function(u){return u.widget("ui.sortable",u.ui.mouse,{version:"1.11.4",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return e<=t&&t*{ cursor: "+r.cursor+" !important; }").appendTo(o)),r.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",r.opacity)),r.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",r.zIndex)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!i)for(s=this.containers.length-1;0<=s;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return u.ui.ddmanager&&(u.ui.ddmanager.current=this),u.ui.ddmanager&&!r.dropBehaviour&&u.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){var e,i,s,o,r=this.options,n=!1;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageYt[this.floating?"width":"height"]?u:r",i.document[0]).addClass(s||i.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tbody"===t?i._createTrPlaceholder(i.currentItem.find("tr").eq(0),u("",i.document[0]).appendTo(e)):"tr"===t?i._createTrPlaceholder(i.currentItem,e):"img"===t&&e.attr("src",i.currentItem.attr("src")),s||e.css("visibility","hidden"),e},update:function(t,e){s&&!o.forcePlaceholderSize||(e.height()||e.height(i.currentItem.innerHeight()-parseInt(i.currentItem.css("paddingTop")||0,10)-parseInt(i.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(i.currentItem.innerWidth()-parseInt(i.currentItem.css("paddingLeft")||0,10)-parseInt(i.currentItem.css("paddingRight")||0,10)))}}),i.placeholder=u(o.placeholder.element.call(i.element,i.currentItem)),i.currentItem.after(i.placeholder),o.placeholder.update(i,i.placeholder)},_createTrPlaceholder:function(t,e){var i=this;t.children().each(function(){u(" | ",i.document[0]).attr("colspan",u(this).attr("colspan")||1).appendTo(e)})},_contactContainers:function(t){var e,i,s,o,r,n,h,a,l,c,p=null,f=null;for(e=this.containers.length-1;0<=e;e--)if(!u.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(p&&u.contains(this.containers[e].element[0],p.element[0]))continue;p=this.containers[e],f=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",t,this._uiHash(this)),this.containers[e].containerCache.over=0);if(p)if(1===this.containers.length)this.containers[f].containerCache.over||(this.containers[f]._trigger("over",t,this._uiHash(this)),this.containers[f].containerCache.over=1);else{for(s=1e4,o=null,r=(l=p.floating||this._isFloating(this.currentItem))?"left":"top",n=l?"width":"height",c=l?"clientX":"clientY",i=this.items.length-1;0<=i;i--)u.contains(this.containers[f].element[0],this.items[i].item[0])&&this.items[i].item[0]!==this.currentItem[0]&&(h=this.items[i].item.offset()[r],a=!1,t[c]-h>this.items[i][n]/2&&(a=!0),Math.abs(t[c]-h)this.containment[2]&&(o=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),s.grid&&(e=this.originalPageY+Math.round((r-this.originalPageY)/s.grid[1])*s.grid[1],r=this.containment?e-this.offset.click.top>=this.containment[1]&&e-this.offset.click.top<=this.containment[3]?e:e-this.offset.click.top>=this.containment[1]?e-s.grid[1]:e+s.grid[1]:e,i=this.originalPageX+Math.round((o-this.originalPageX)/s.grid[0])*s.grid[0],o=this.containment?i-this.offset.click.left>=this.containment[0]&&i-this.offset.click.left<=this.containment[2]?i:i-this.offset.click.left>=this.containment[0]?i-s.grid[0]:i+s.grid[0]:i)),{top:r-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():h?0:n.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():h?0:n.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var o=this.counter;this._delay(function(){o===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){this.reverting=!1;var i,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)"auto"!==this._storedCSS[i]&&"static"!==this._storedCSS[i]||(this._storedCSS[i]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();function o(e,i,s){return function(t){s._trigger(e,t,i._uiHash(i))}}for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;0<=i;i--)e||s.push(o("deactivate",this,this.containers[i])),this.containers[i].containerCache.over&&(s.push(o("out",this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(i=0;i 1);
$container.find('.iwjmb-input').each(function (){
toggleRemoveButtons($(this));
});
}
function toggleAddButton($container){
var $button=$container.find('.add-clone'),
maxClone=parseInt($container.data('max-clone')),
numClone=$container.find('.iwjmb-clone').length;
$button.toggle(isNaN(maxClone)||(maxClone&&numClone < maxClone));
}
$('#wpbody-content, body.page')
.on('click', '.add-clone', function (e){
e.preventDefault();
var $container=$(this).closest('.iwjmb-input');
clone($container);
toggleRemoveButtons($container);
toggleAddButton($container);
})
.on('click', '.remove-clone', function (e){
e.preventDefault();
var $this=$(this),
$container=$this.closest('.iwjmb-input');
if($container.children('.iwjmb-clone').length < 2){
return;
}
$this.parent().trigger('remove').remove();
toggleRemoveButtons($container);
toggleAddButton($container)
});
$('.iwjmb-input').each(function (){
var $container=$(this);
toggleRemoveButtons($container);
toggleAddButton($container);
$container
.data('next-index', $container.children('.iwjmb-clone').length)
.sortable({
handle: '.iwjmb-clone-icon',
placeholder: ' iwjmb-clone iwjmb-clone-placeholder',
items: '.iwjmb-clone',
start: function (event, ui){
ui.placeholder.height(ui.item.height());
}});
});
});
!function ($){
"use strict";
if(typeof ko!=='undefined'&&ko.bindingHandlers&&!ko.bindingHandlers.multiselect){
ko.bindingHandlers.multiselect={
after: ['options', 'value', 'selectedOptions', 'enable', 'disable'],
init: function(element, valueAccessor, allBindings, viewModel, bindingContext){
var $element=$(element);
var config=ko.toJS(valueAccessor());
$element.multiselect(config);
if(allBindings.has('options')){
var options=allBindings.get('options');
if(ko.isObservable(options)){
ko.computed({
read: function(){
options();
setTimeout(function(){
var ms=$element.data('multiselect');
if(ms)
ms.updateOriginalOptions();
$element.multiselect('rebuild');
}, 1);
},
disposeWhenNodeIsRemoved: element
});
}}
if(allBindings.has('value')){
var value=allBindings.get('value');
if(ko.isObservable(value)){
ko.computed({
read: function(){
value();
setTimeout(function(){
$element.multiselect('refresh');
}, 1);
},
disposeWhenNodeIsRemoved: element
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
}}
if(allBindings.has('selectedOptions')){
var selectedOptions=allBindings.get('selectedOptions');
if(ko.isObservable(selectedOptions)){
ko.computed({
read: function(){
selectedOptions();
setTimeout(function(){
$element.multiselect('refresh');
}, 1);
},
disposeWhenNodeIsRemoved: element
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
}}
var setEnabled=function (enable){
setTimeout(function (){
if(enable)
$element.multiselect('enable');
else
$element.multiselect('disable');
});
};
if(allBindings.has('enable')){
var enable=allBindings.get('enable');
if(ko.isObservable(enable)){
ko.computed({
read: function (){
setEnabled(enable());
},
disposeWhenNodeIsRemoved: element
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
}else{
setEnabled(enable);
}}
if(allBindings.has('disable')){
var disable=allBindings.get('disable');
if(ko.isObservable(disable)){
ko.computed({
read: function (){
setEnabled(!disable());
},
disposeWhenNodeIsRemoved: element
}).extend({ rateLimit: 100, notifyWhenChangesStop: true });
}else{
setEnabled(!disable);
}}
ko.utils.domNodeDisposal.addDisposeCallback(element, function(){
$element.multiselect('destroy');
});
},
update: function(element, valueAccessor, allBindings, viewModel, bindingContext){
var $element=$(element);
var config=ko.toJS(valueAccessor());
$element.multiselect('setOptions', config);
$element.multiselect('rebuild');
}};}
function forEach(array, callback){
for (var index=0; index < array.length; ++index){
callback(array[index], index);
}}
function Multiselect(select, options){
this.$select=$(select);
this.options=this.mergeOptions($.extend({}, options, this.$select.data()));
if(this.$select.attr("data-placeholder")){
this.options.nonSelectedText=this.$select.data("placeholder");
}
this.originalOptions=this.$select.clone()[0].options;
this.query='';
this.searchTimeout=null;
this.lastToggledInput=null;
this.options.multiple=this.$select.attr('multiple')==="multiple";
this.options.onChange=$.proxy(this.options.onChange, this);
this.options.onSelectAll=$.proxy(this.options.onSelectAll, this);
this.options.onDeselectAll=$.proxy(this.options.onDeselectAll, this);
this.options.onDropdownShow=$.proxy(this.options.onDropdownShow, this);
this.options.onDropdownHide=$.proxy(this.options.onDropdownHide, this);
this.options.onDropdownShown=$.proxy(this.options.onDropdownShown, this);
this.options.onDropdownHidden=$.proxy(this.options.onDropdownHidden, this);
this.options.onInitialized=$.proxy(this.options.onInitialized, this);
this.options.onFiltering=$.proxy(this.options.onFiltering, this);
this.buildContainer();
this.buildButton();
this.buildDropdown();
this.buildSelectAll();
this.buildDropdownOptions();
this.buildFilter();
this.updateButtonText();
this.updateSelectAll(true);
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}
this.options.wasDisabled=this.$select.prop('disabled');
if(this.options.disableIfEmpty&&$('option', this.$select).length <=0){
this.disable();
}
this.$select.wrap('').after(this.$container);
this.options.onInitialized(this.$select, this.$container);
}
Multiselect.prototype={
defaults: {
buttonText: function(options, select){
if(this.disabledText.length > 0
&& (select.prop('disabled')||(options.length==0&&this.disableIfEmpty))){
return this.disabledText;
}
else if(options.length===0){
return this.nonSelectedText;
}
else if(this.allSelectedText
&& options.length===$('option', $(select)).length
&& $('option', $(select)).length!==1
&& this.multiple){
if(this.selectAllNumber){
return this.allSelectedText + ' (' + options.length + ')';
}else{
return this.allSelectedText;
}}
else if(options.length > this.numberDisplayed){
return options.length + ' ' + this.nSelectedText;
}else{
var selected='';
var delimiter=this.delimiterText;
options.each(function(){
var label=($(this).attr('label')!==undefined) ? $(this).attr('label'):$(this).text();
selected +=label + delimiter;
});
return selected.substr(0, selected.length - this.delimiterText.length);
}},
buttonTitle: function(options, select){
if(options.length===0){
return this.nonSelectedText;
}else{
var selected='';
var delimiter=this.delimiterText;
options.each(function (){
var label=($(this).attr('label')!==undefined) ? $(this).attr('label'):$(this).text();
selected +=label + delimiter;
});
return selected.substr(0, selected.length - this.delimiterText.length);
}},
checkboxName: function(option){
return false;
},
optionLabel: function(element){
return $(element).attr('label')||$(element).text();
},
optionClass: function(element){
return $(element).attr('class')||'';
},
onChange:function(option, checked){
},
onDropdownShow: function(event){
},
onDropdownHide: function(event){
},
onDropdownShown: function(event){
},
onDropdownHidden: function(event){
},
onSelectAll: function(){
},
onDeselectAll: function(){
},
onInitialized: function($select, $container){
},
onFiltering: function($filter){
},
enableHTML: false,
buttonClass: 'btn btn-default',
inheritClass: false,
buttonWidth: 'auto',
buttonContainer: '',
dropRight: false,
dropUp: false,
selectedClass: 'active',
maxHeight: false,
includeSelectAllOption: false,
includeSelectAllIfMoreThan: 0,
selectAllText: i18niwjmbmultiselect.selectAllText,
selectAllValue: 'multiselect-all',
selectAllName: false,
selectAllNumber: true,
selectAllJustVisible: true,
enableFiltering: false,
enableCaseInsensitiveFiltering: false,
enableFullValueFiltering: false,
enableClickableOptGroups: false,
enableCollapsibleOptGroups: false,
filterPlaceholder: i18niwjmbmultiselect.filterPlaceholder,
filterBehavior: 'text',
includeFilterClearBtn: true,
preventInputChangeEvent: false,
nonSelectedText: i18niwjmbmultiselect.nonSelectedText,
nSelectedText: 'selected',
allSelectedText: i18niwjmbmultiselect.allSelectedText,
numberDisplayed: 3,
disableIfEmpty: false,
disabledText: '',
delimiterText: ', ',
templates: {
button: '',
ul: '',
filter: '
',
filterClearBtn: '',
li: '',
divider: '',
liGroup: ''
}},
constructor: Multiselect,
buildContainer: function(){
this.$container=$(this.options.buttonContainer);
this.$container.on('show.bs.dropdown', this.options.onDropdownShow);
this.$container.on('hide.bs.dropdown', this.options.onDropdownHide);
this.$container.on('shown.bs.dropdown', this.options.onDropdownShown);
this.$container.on('hidden.bs.dropdown', this.options.onDropdownHidden);
},
buildButton: function(){
this.$button=$(this.options.templates.button).addClass(this.options.buttonClass);
if(this.$select.attr('class')&&this.options.inheritClass){
this.$button.addClass(this.$select.attr('class'));
}
if(this.$select.prop('disabled')){
this.disable();
}else{
this.enable();
}
if(this.options.buttonWidth&&this.options.buttonWidth!=='auto'){
this.$button.css({
'width':'100%', //this.options.buttonWidth,
'overflow':'hidden',
'text-overflow':'ellipsis'
});
this.$container.css({
'width': this.options.buttonWidth
});
}
var tabindex=this.$select.attr('tabindex');
if(tabindex){
this.$button.attr('tabindex', tabindex);
}
this.$container.prepend(this.$button);
},
buildDropdown: function(){
this.$ul=$(this.options.templates.ul);
if(this.options.dropRight){
this.$ul.addClass('pull-right');
}
if(this.options.maxHeight){
this.$ul.css({
'max-height': this.options.maxHeight + 'px',
'overflow-y': 'auto',
'overflow-x': 'hidden'
});
}
if(this.options.dropUp){
var height=Math.min(this.options.maxHeight, $('option[data-role!="divider"]', this.$select).length*26 + $('option[data-role="divider"]', this.$select).length*19 + (this.options.includeSelectAllOption ? 26:0) + (this.options.enableFiltering||this.options.enableCaseInsensitiveFiltering ? 44:0));
var moveCalc=height + 34;
this.$ul.css({
'max-height': height + 'px',
'overflow-y': 'auto',
'overflow-x': 'hidden',
'margin-top': "-" + moveCalc + 'px'
});
}
this.$container.append(this.$ul);
},
buildDropdownOptions: function(){
this.$select.children().each($.proxy(function(index, element){
var $element=$(element);
var tag=$element.prop('tagName')
.toLowerCase();
if($element.prop('value')===this.options.selectAllValue){
return;
}
if(tag==='optgroup'){
this.createOptgroup(element);
}
else if(tag==='option'){
if($element.data('role')==='divider'){
this.createDivider();
}else{
this.createOptionValue(element);
}}
}, this));
$('li:not(.multiselect-group) input', this.$ul).on('change', $.proxy(function(event){
var $target=$(event.target);
var checked=$target.prop('checked')||false;
var isSelectAllOption=$target.val()===this.options.selectAllValue;
if(this.options.selectedClass){
if(checked){
$target.closest('li')
.addClass(this.options.selectedClass);
}else{
$target.closest('li')
.removeClass(this.options.selectedClass);
}}
var value=$target.val();
var $option=this.getOptionByValue(value);
var $optionsNotThis=$('option', this.$select).not($option);
var $checkboxesNotThis=$('input', this.$container).not($target);
if(isSelectAllOption){
if(checked){
this.selectAll(this.options.selectAllJustVisible, true);
}else{
this.deselectAll(this.options.selectAllJustVisible, true);
}}else{
if(checked){
$option.prop('selected', true);
if(this.options.multiple){
$option.prop('selected', true);
}else{
if(this.options.selectedClass){
$($checkboxesNotThis).closest('li').removeClass(this.options.selectedClass);
}
$($checkboxesNotThis).prop('checked', false);
$optionsNotThis.prop('selected', false);
this.$button.click();
}
if(this.options.selectedClass==="active"){
$optionsNotThis.closest("a").css("outline", "");
}}else{
$option.prop('selected', false);
}
this.options.onChange($option, checked);
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}}
this.$select.change();
this.updateButtonText();
if(this.options.preventInputChangeEvent){
return false;
}}, this));
$('li a', this.$ul).on('mousedown', function(e){
if(e.shiftKey){
return false;
}});
$('li a', this.$ul).on('touchstart click', $.proxy(function(event){
event.stopPropagation();
var $target=$(event.target);
if(event.shiftKey&&this.options.multiple){
if($target.is("label")){
event.preventDefault();
$target=$target.find("input");
$target.prop("checked", !$target.prop("checked"));
}
var checked=$target.prop('checked')||false;
if(this.lastToggledInput!==null&&this.lastToggledInput!==$target){
var from=$target.closest("li").index();
var to=this.lastToggledInput.closest("li").index();
if(from > to){
var tmp=to;
to=from;
from=tmp;
}
++to;
var range=this.$ul.find("li").slice(from, to).find("input");
range.prop('checked', checked);
if(this.options.selectedClass){
range.closest('li')
.toggleClass(this.options.selectedClass, checked);
}
for (var i=0, j=range.length; i < j; i++){
var $checkbox=$(range[i]);
var $option=this.getOptionByValue($checkbox.val());
$option.prop('selected', checked);
}}
$target.trigger("change");
}
if($target.is("input")&&!$target.closest("li").is(".multiselect-item")){
this.lastToggledInput=$target;
}
$target.blur();
}, this));
this.$container.off('keydown.multiselect').on('keydown.multiselect', $.proxy(function(event){
if($('input[type="text"]', this.$container).is(':focus')){
return;
}
if(event.keyCode===9&&this.$container.hasClass('open')){
this.$button.click();
}else{
var $items=$(this.$container).find("li:not(.divider):not(.disabled) a").filter(":visible");
if(!$items.length){
return;
}
var index=$items.index($items.filter(':focus'));
if(event.keyCode===38&&index > 0){
index--;
}
else if(event.keyCode===40&&index < $items.length - 1){
index++;
}
else if(!~index){
index=0;
}
var $current=$items.eq(index);
$current.focus();
if(event.keyCode===32||event.keyCode===13){
var $checkbox=$current.find('input');
$checkbox.prop("checked", !$checkbox.prop("checked"));
$checkbox.change();
}
event.stopPropagation();
event.preventDefault();
}}, this));
if(this.options.enableClickableOptGroups&&this.options.multiple){
$("li.multiselect-group input", this.$ul).on("change", $.proxy(function(event){
event.stopPropagation();
var $target=$(event.target);
var checked=$target.prop('checked')||false;
var $li=$(event.target).closest('li');
var $group=$li.nextUntil("li.multiselect-group")
.not('.multiselect-filter-hidden')
.not('.disabled');
var $inputs=$group.find("input");
var values=[];
var $options=[];
if(this.options.selectedClass){
if(checked){
$li.addClass(this.options.selectedClass);
}else{
$li.removeClass(this.options.selectedClass);
}}
$.each($inputs, $.proxy(function(index, input){
var value=$(input).val();
var $option=this.getOptionByValue(value);
if(checked){
$(input).prop('checked', true);
$(input).closest('li')
.addClass(this.options.selectedClass);
$option.prop('selected', true);
}else{
$(input).prop('checked', false);
$(input).closest('li')
.removeClass(this.options.selectedClass);
$option.prop('selected', false);
}
$options.push(this.getOptionByValue(value));
}, this))
this.options.onChange($options, checked);
this.updateButtonText();
this.updateSelectAll();
}, this));
}
if(this.options.enableCollapsibleOptGroups&&this.options.multiple){
$("li.multiselect-group .caret-container", this.$ul).on("click", $.proxy(function(event){
var $li=$(event.target).closest('li');
var $inputs=$li.nextUntil("li.multiselect-group")
.not('.multiselect-filter-hidden');
var visible=true;
$inputs.each(function(){
visible=visible&&$(this).is(':visible');
});
if(visible){
$inputs.hide()
.addClass('multiselect-collapsible-hidden');
}else{
$inputs.show()
.removeClass('multiselect-collapsible-hidden');
}}, this));
$("li.multiselect-all", this.$ul).css('background', '#f3f3f3').css('border-bottom', '1px solid #eaeaea');
$("li.multiselect-all > a > label.checkbox", this.$ul).css('padding', '3px 20px 3px 35px');
$("li.multiselect-group > a > input", this.$ul).css('margin', '4px 0px 5px -20px');
}},
createOptionValue: function(element){
var $element=$(element);
if($element.is(':selected')){
$element.prop('selected', true);
}
var label=this.options.optionLabel(element);
var classes=this.options.optionClass(element);
var value=$element.val();
var inputType=this.options.multiple ? "checkbox":"radio";
var $li=$(this.options.templates.li);
var $label=$('label', $li);
$label.addClass(inputType);
$li.addClass(classes);
if(this.options.enableHTML){
$label.html(" " + label);
}else{
$label.text(" " + label);
}
var $checkbox=$('').attr('type', inputType);
var name=this.options.checkboxName($element);
if(name){
$checkbox.attr('name', name);
}
$label.prepend($checkbox);
var selected=$element.prop('selected')||false;
$checkbox.val(value);
if(value===this.options.selectAllValue){
$li.addClass("multiselect-item multiselect-all");
$checkbox.parent().parent()
.addClass('multiselect-all');
}
$label.attr('title', $element.attr('title'));
this.$ul.append($li);
if($element.is(':disabled')){
$checkbox.attr('disabled', 'disabled')
.prop('disabled', true)
.closest('a')
.attr("tabindex", "-1")
.closest('li')
.addClass('disabled');
}
$checkbox.prop('checked', selected);
if(selected&&this.options.selectedClass){
$checkbox.closest('li')
.addClass(this.options.selectedClass);
}},
createDivider: function(element){
var $divider=$(this.options.templates.divider);
this.$ul.append($divider);
},
createOptgroup: function(group){
var label=$(group).attr("label");
var value=$(group).attr("value");
var $li=$('');
var classes=this.options.optionClass(group);
$li.addClass(classes);
if(this.options.enableHTML){
$('label b', $li).html(" " + label);
}else{
$('label b', $li).text(" " + label);
}
if(this.options.enableCollapsibleOptGroups&&this.options.multiple){
$('a', $li).append('');
}
if(this.options.enableClickableOptGroups&&this.options.multiple){
$('a label', $li).prepend('');
}
if($(group).is(':disabled')){
$li.addClass('disabled');
}
this.$ul.append($li);
$("option", group).each($.proxy(function($, group){
this.createOptionValue(group);
}, this))
},
buildSelectAll: function(){
if(typeof this.options.selectAllValue==='number'){
this.options.selectAllValue=this.options.selectAllValue.toString();
}
var alreadyHasSelectAll=this.hasSelectAll();
if(!alreadyHasSelectAll&&this.options.includeSelectAllOption&&this.options.multiple
&& $('option', this.$select).length > this.options.includeSelectAllIfMoreThan){
if(this.options.includeSelectAllDivider){
this.$ul.prepend($(this.options.templates.divider));
}
var $li=$(this.options.templates.li);
$('label', $li).addClass("checkbox");
if(this.options.enableHTML){
$('label', $li).html(" " + this.options.selectAllText);
}else{
$('label', $li).text(" " + this.options.selectAllText);
}
if(this.options.selectAllName){
$('label', $li).prepend('');
}else{
$('label', $li).prepend('');
}
var $checkbox=$('input', $li);
$checkbox.val(this.options.selectAllValue);
$li.addClass("multiselect-item multiselect-all");
$checkbox.parent().parent()
.addClass('multiselect-all');
this.$ul.prepend($li);
$checkbox.prop('checked', false);
}},
buildFilter: function(){
if(this.options.enableFiltering||this.options.enableCaseInsensitiveFiltering){
var enableFilterLength=Math.max(this.options.enableFiltering, this.options.enableCaseInsensitiveFiltering);
if(this.$select.find('option').length >=enableFilterLength){
this.$filter=$(this.options.templates.filter);
$('input', this.$filter).attr('placeholder', this.options.filterPlaceholder);
if(this.options.includeFilterClearBtn){
var clearBtn=$(this.options.templates.filterClearBtn);
clearBtn.on('click', $.proxy(function(event){
clearTimeout(this.searchTimeout);
this.$filter.find('.multiselect-search').val('');
$('li', this.$ul).show().removeClass('multiselect-filter-hidden');
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}}, this));
this.$filter.find('.input-group').append(clearBtn);
}
this.$ul.prepend(this.$filter);
this.$filter.val(this.query).on('click', function(event){
event.stopPropagation();
}).on('input keydown', $.proxy(function(event){
if(event.which===13){
event.preventDefault();
}
clearTimeout(this.searchTimeout);
this.searchTimeout=this.asyncFunction($.proxy(function(){
if(this.query!==event.target.value){
this.query=event.target.value;
var currentGroup, currentGroupVisible;
$.each($('li', this.$ul), $.proxy(function(index, element){
var value=$('input', element).length > 0 ? $('input', element).val():"";
var text=$('label', element).text();
var filterCandidate='';
if((this.options.filterBehavior==='text')){
filterCandidate=text;
}
else if((this.options.filterBehavior==='value')){
filterCandidate=value;
}
else if(this.options.filterBehavior==='both'){
filterCandidate=text + '\n' + value;
}
if(value!==this.options.selectAllValue&&text){
var showElement=false;
if(this.options.enableCaseInsensitiveFiltering){
filterCandidate=filterCandidate.toLowerCase();
this.query=this.query.toLowerCase();
}
if(this.options.enableFullValueFiltering&&this.options.filterBehavior!=='both'){
var valueToMatch=filterCandidate.trim().substring(0, this.query.length);
if(this.query.indexOf(valueToMatch) > -1){
showElement=true;
}}
else if(filterCandidate.indexOf(this.query) > -1){
showElement=true;
}
$(element).toggle(showElement)
.toggleClass('multiselect-filter-hidden', !showElement);
if($(element).hasClass('multiselect-group')){
currentGroup=element;
currentGroupVisible=showElement;
}else{
if(showElement){
$(currentGroup).show()
.removeClass('multiselect-filter-hidden');
}
if(!showElement&¤tGroupVisible){
$(element).show()
.removeClass('multiselect-filter-hidden');
}}
}}, this));
}
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}
this.options.onFiltering(event.target);
}, this), 300, this);
}, this));
}}
},
destroy: function(){
this.$container.remove();
this.$select.show();
this.$select.prop('disabled', this.options.wasDisabled);
this.$select.data('multiselect', null);
},
refresh: function (){
var inputs=$.map($('li input', this.$ul), $);
$('option', this.$select).each($.proxy(function (index, element){
var $elem=$(element);
var value=$elem.val();
var $input;
for (var i=inputs.length; 0 < i--; ){
if(value!==($input=inputs[i]).val())
continue;
if($elem.is(':selected')){
$input.prop('checked', true);
if(this.options.selectedClass){
$input.closest('li')
.addClass(this.options.selectedClass);
}}else{
$input.prop('checked', false);
if(this.options.selectedClass){
$input.closest('li')
.removeClass(this.options.selectedClass);
}}
if($elem.is(":disabled")){
$input.attr('disabled', 'disabled')
.prop('disabled', true)
.closest('li')
.addClass('disabled');
}else{
$input.prop('disabled', false)
.closest('li')
.removeClass('disabled');
}
break;
}}, this));
this.updateButtonText();
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}},
select: function(selectValues, triggerOnChange){
if(!$.isArray(selectValues)){
selectValues=[selectValues];
}
for (var i=0; i < selectValues.length; i++){
var value=selectValues[i];
if(value===null||value===undefined){
continue;
}
var $option=this.getOptionByValue(value);
var $checkbox=this.getInputByValue(value);
if($option===undefined||$checkbox===undefined){
continue;
}
if(!this.options.multiple){
this.deselectAll(false);
}
if(this.options.selectedClass){
$checkbox.closest('li')
.addClass(this.options.selectedClass);
}
$checkbox.prop('checked', true);
$option.prop('selected', true);
if(triggerOnChange){
this.options.onChange($option, true);
}}
this.updateButtonText();
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}},
clearSelection: function (){
this.deselectAll(false);
this.updateButtonText();
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}},
deselect: function(deselectValues, triggerOnChange){
if(!$.isArray(deselectValues)){
deselectValues=[deselectValues];
}
for (var i=0; i < deselectValues.length; i++){
var value=deselectValues[i];
if(value===null||value===undefined){
continue;
}
var $option=this.getOptionByValue(value);
var $checkbox=this.getInputByValue(value);
if($option===undefined||$checkbox===undefined){
continue;
}
if(this.options.selectedClass){
$checkbox.closest('li')
.removeClass(this.options.selectedClass);
}
$checkbox.prop('checked', false);
$option.prop('selected', false);
if(triggerOnChange){
this.options.onChange($option, false);
}}
this.updateButtonText();
this.updateSelectAll();
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}},
selectAll: function (justVisible, triggerOnSelectAll){
var justVisible=typeof justVisible==='undefined' ? true:justVisible;
var allLis=$("li:not(.divider):not(.disabled):not(.multiselect-group)", this.$ul);
var visibleLis=$("li:not(.divider):not(.disabled):not(.multiselect-group):not(.multiselect-filter-hidden):not(.multiselect-collapisble-hidden)", this.$ul).filter(':visible');
if(justVisible){
$('input:enabled' , visibleLis).prop('checked', true);
visibleLis.addClass(this.options.selectedClass);
$('input:enabled' , visibleLis).each($.proxy(function(index, element){
var value=$(element).val();
var option=this.getOptionByValue(value);
$(option).prop('selected', true);
}, this));
}else{
$('input:enabled' , allLis).prop('checked', true);
allLis.addClass(this.options.selectedClass);
$('input:enabled' , allLis).each($.proxy(function(index, element){
var value=$(element).val();
var option=this.getOptionByValue(value);
$(option).prop('selected', true);
}, this));
}
$('li input[value="' + this.options.selectAllValue + '"]', this.$ul).prop('checked', true);
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}
if(triggerOnSelectAll){
this.options.onSelectAll();
}},
deselectAll: function (justVisible, triggerOnDeselectAll){
var justVisible=typeof justVisible==='undefined' ? true:justVisible;
var allLis=$("li:not(.divider):not(.disabled):not(.multiselect-group)", this.$ul);
var visibleLis=$("li:not(.divider):not(.disabled):not(.multiselect-group):not(.multiselect-filter-hidden):not(.multiselect-collapisble-hidden)", this.$ul).filter(':visible');
if(justVisible){
$('input[type="checkbox"]:enabled' , visibleLis).prop('checked', false);
visibleLis.removeClass(this.options.selectedClass);
$('input[type="checkbox"]:enabled' , visibleLis).each($.proxy(function(index, element){
var value=$(element).val();
var option=this.getOptionByValue(value);
$(option).prop('selected', false);
}, this));
}else{
$('input[type="checkbox"]:enabled' , allLis).prop('checked', false);
allLis.removeClass(this.options.selectedClass);
$('input[type="checkbox"]:enabled' , allLis).each($.proxy(function(index, element){
var value=$(element).val();
var option=this.getOptionByValue(value);
$(option).prop('selected', false);
}, this));
}
$('li input[value="' + this.options.selectAllValue + '"]', this.$ul).prop('checked', false);
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}
if(triggerOnDeselectAll){
this.options.onDeselectAll();
}},
rebuild: function(){
this.$ul.html('');
this.options.multiple=this.$select.attr('multiple')==="multiple";
this.buildSelectAll();
this.buildDropdownOptions();
this.buildFilter();
this.updateButtonText();
this.updateSelectAll(true);
if(this.options.enableClickableOptGroups&&this.options.multiple){
this.updateOptGroups();
}
if(this.options.disableIfEmpty&&$('option', this.$select).length <=0){
this.disable();
}else{
this.enable();
}
if(this.options.dropRight){
this.$ul.addClass('pull-right');
}},
dataprovider: function(dataprovider){
var groupCounter=0;
var $select=this.$select.empty();
$.each(dataprovider, function (index, option){
var $tag;
if($.isArray(option.children)){
groupCounter++;
$tag=$('').attr({
label: option.label||'Group ' + groupCounter,
disabled: !!option.disabled
});
forEach(option.children, function(subOption){
var attributes={
value: subOption.value,
label: subOption.label||subOption.value,
title: subOption.title,
selected: !!subOption.selected,
disabled: !!subOption.disabled
};
for (var key in subOption.attributes){
attributes['data-' + key]=subOption.attributes[key];
}
$tag.append($('').attr(attributes));
});
}else{
var attributes={
'value': option.value,
'label': option.label||option.value,
'title': option.title,
'class': option.class,
'selected': !!option.selected,
'disabled': !!option.disabled
};
for (var key in option.attributes){
attributes['data-' + key]=option.attributes[key];
}
$tag=$('').attr(attributes);
$tag.text(option.label||option.value);
}
$select.append($tag);
});
this.rebuild();
},
enable: function(){
this.$select.prop('disabled', false);
this.$button.prop('disabled', false)
.removeClass('disabled');
},
disable: function(){
this.$select.prop('disabled', true);
this.$button.prop('disabled', true)
.addClass('disabled');
},
setOptions: function(options){
this.options=this.mergeOptions(options);
},
mergeOptions: function(options){
return $.extend(true, {}, this.defaults, this.options, options);
},
hasSelectAll: function(){
return $('li.multiselect-all', this.$ul).length > 0;
},
updateOptGroups: function(){
var $groups=$('li.multiselect-group', this.$ul)
var selectedClass=this.options.selectedClass;
$groups.each(function(){
var $options=$(this).nextUntil('li.multiselect-group')
.not('.multiselect-filter-hidden')
.not('.disabled');
var checked=true;
$options.each(function(){
var $input=$('input', this);
if(!$input.prop('checked')){
checked=false;
}});
if(selectedClass){
if(checked){
$(this).addClass(selectedClass);
}else{
$(this).removeClass(selectedClass);
}}
$('input', this).prop('checked', checked);
});
},
updateSelectAll: function(notTriggerOnSelectAll){
if(this.hasSelectAll()){
var allBoxes=$("li:not(.multiselect-item):not(.multiselect-filter-hidden):not(.multiselect-group):not(.disabled) input:enabled", this.$ul);
var allBoxesLength=allBoxes.length;
var checkedBoxesLength=allBoxes.filter(":checked").length;
var selectAllLi=$("li.multiselect-all", this.$ul);
var selectAllInput=selectAllLi.find("input");
if(checkedBoxesLength > 0&&checkedBoxesLength===allBoxesLength){
selectAllInput.prop("checked", true);
selectAllLi.addClass(this.options.selectedClass);
}else{
selectAllInput.prop("checked", false);
selectAllLi.removeClass(this.options.selectedClass);
}}
},
updateButtonText: function(){
var options=this.getSelected();
if(this.options.enableHTML){
$('.multiselect .multiselect-selected-text', this.$container).html(this.options.buttonText(options, this.$select));
}else{
$('.multiselect .multiselect-selected-text', this.$container).text(this.options.buttonText(options, this.$select));
}
$('.multiselect', this.$container).attr('title', this.options.buttonTitle(options, this.$select));
},
getSelected: function(){
return $('option', this.$select).filter(":selected");
},
getOptionByValue: function (value){
var options=$('option', this.$select);
var valueToCompare=value.toString();
for (var i=0; i < options.length; i=i + 1){
var option=options[i];
if(option.value===valueToCompare){
return $(option);
}}
},
getInputByValue: function (value){
var checkboxes=$('li input:not(.multiselect-search)', this.$ul);
var valueToCompare=value.toString();
for (var i=0; i < checkboxes.length; i=i + 1){
var checkbox=checkboxes[i];
if(checkbox.value===valueToCompare){
return $(checkbox);
}}
},
updateOriginalOptions: function(){
this.originalOptions=this.$select.clone()[0].options;
},
asyncFunction: function(callback, timeout, self){
var args=Array.prototype.slice.call(arguments, 3);
return setTimeout(function(){
callback.apply(self||window, args);
}, timeout);
},
setAllSelectedText: function(allSelectedText){
this.options.allSelectedText=allSelectedText;
this.updateButtonText();
}};
$.fn.multiselect=function(option, parameter, extraOptions){
return this.each(function(){
var data=$(this).data('multiselect');
var options=typeof option==='object'&&option;
if(!data){
data=new Multiselect(this, options);
$(this).data('multiselect', data);
}
if(typeof option==='string'){
data[option](parameter, extraOptions);
if(option==='destroy'){
$(this).data('multiselect', false);
}}
});
};
$.fn.multiselect.Constructor=Multiselect;
$(function(){
$("select[data-role=multiselect]").multiselect();
});
}(window.jQuery);
jQuery(function($){
'use strict';
function update(){
function htmlDecode(value){
return $("").html(value).text();
}
var $this=$(this);
var options=$this.data('options');
if(!options){
options={}}
if(!options.selectAllText){
options.selectAllText=i18niwjmbTaxonomy2.selectAllText;
}
if(!options.filterPlaceholder){
options.filterPlaceholder=i18niwjmbTaxonomy2.filterPlaceholder;
}
if(!options.filterPlaceholder){
options.nonSelectedText=i18niwjmbTaxonomy2.nonSelectedText;
}
options.allSelectedText=i18niwjmbTaxonomy2.allSelectedText;
options.onChange=function(option, checked){
var $select=$(this.$select.get(0));
var max_items=options.maxSelectItems ? options.maxSelectItems:'';
if(max_items){
var selectedOptions=$select.find('option:selected');
if(selectedOptions.length >=max_items){
var nonSelectedOptions=$select.find('option').filter(function(){
return !$(this).is(':selected');
});
nonSelectedOptions.each(function(){
var input=$('input[value="' + $(this).val() + '"]');
input.prop('disabled', true);
input.parent('li').addClass('disabled');
});
}else{
$select.find('option').each(function(){
var input=$('input[value="' + $(this).val() + '"]');
input.prop('disabled', false);
input.parent('li').addClass('disabled');
});
}}
};
options.buttonText=function(options, select){
if(options.length==0){
return this.nonSelectedText;
}else{
var selected=[];
var i=0;
var numberDisplayed=this.numberDisplayed;
options.each(function(){
var label=($(this).attr('label')!==undefined) ? $(this).attr('label'):$(this).html();
if(i < numberDisplayed){
selected.push(label);
}else{
selected.push('...('+options.length+')');
return false;
}
i++;
});
return htmlDecode(selected.join(', '));
}};
options.onDropdownShow=function(options, select){
if(!this.$ul.mark_checkbox){
$(this.$ul).find('input[type="checkbox"]').after('');
this.$ul.mark_checkbox=true;
}};
options.optionClass=function(element){
var level=$(element).data('level');
if(level){
return 'level-'+level;
}else{
return '';
}};
$this.multiselect(options);
}
$(':input.iwjmb-taxonomy2').each(update);
$('.iwjmb-input').on('clone', ':input.iwjmb-taxonomy2', update);
});
jQuery(function($){
'use strict';
var select=window.iwjmbSelect={
selectAllNone: function($input){
var $element=$input.find('select');
$input.on('click', '.iwjmb-select-all-none a', function(e){
e.preventDefault();
if('all'==$(this).data('type')){
var selected=[];
$element.find('option').each(function(i, e){
var $value=$(e).attr('value');
if($value!=''){
selected.push($value);
}});
$element.val(selected).trigger('change');
}else{
$element.val('');
}});
},
bindEvents: function($el){
var $input=$el.closest('.iwjmb-input'),
$clone=$input.find('.iwjmb-clone');
if($clone.length){
$clone.each(function (){
select.selectAllNone($(this));
});
}else{
select.selectAllNone($input);
}}
};
function update(){
select.bindEvents($(this));
}
$(':input.iwjmb-select').each(update);
$('.iwjmb-input').on('clone', ':input.iwjmb-select', update);
});
jQuery(function($){
'use strict';
function update(){
var $this=$(this),
options=$this.data('options');
if(typeof options==='undefined'||!options){
options={}}
if(options&&(options.minimumResultsForSearch&&(options.minimumResultsForSearch==-1||options.minimumResultsForSearch=='Infinity'))||options.multiple){
options.dropdownCssClass='iwj-select-2-wsearch';
}
options.dropdownParent=$this.parents('body');
$this.siblings('.select2-container').remove();
$this.show().select2(options);
iwjmbSelect.bindEvents($this);
}
$(':input.iwjmb-select_advanced').each(update);
$('.iwjmb-input').on('clone', ':input.iwjmb-select_advanced', update);
});